sdl.pas 154 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153
  1. unit sdl;
  2. {
  3. $Id: sdl.pas,v 1.17 2005/01/03 18:40:59 savage Exp $
  4. }
  5. {******************************************************************************}
  6. { }
  7. { JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
  8. { Conversion of the Simple DirectMedia Layer Headers }
  9. { }
  10. { Portions created by Sam Lantinga <[email protected]> are }
  11. { Copyright (C) 1997-2004 Sam Lantinga }
  12. { 5635-34 Springhouse Dr. }
  13. { Pleasanton, CA 94588 (USA) }
  14. { }
  15. { All Rights Reserved. }
  16. { }
  17. { The original files are : SDL.h }
  18. { SDL_main.h }
  19. { SDL_types.h }
  20. { SDL_rwops.h }
  21. { SDL_timer.h }
  22. { SDL_audio.h }
  23. { SDL_cdrom.h }
  24. { SDL_joystick.h }
  25. { SDL_mouse.h }
  26. { SDL_keyboard.h }
  27. { SDL_events.h }
  28. { SDL_video.h }
  29. { SDL_byteorder.h }
  30. { SDL_version.h }
  31. { SDL_active.h }
  32. { SDL_thread.h }
  33. { SDL_mutex .h }
  34. { SDL_getenv.h }
  35. { SDL_loadso.h }
  36. { }
  37. { The initial developer of this Pascal code was : }
  38. { Dominqiue Louis <[email protected]> }
  39. { }
  40. { Portions created by Dominqiue Louis are }
  41. { Copyright (C) 2000 - 2004 Dominqiue Louis. }
  42. { }
  43. { }
  44. { Contributor(s) }
  45. { -------------- }
  46. { Tom Jones <[email protected]> His Project inspired this conversion }
  47. { Matthias Thoma <[email protected]> }
  48. { }
  49. { Obtained through: }
  50. { Joint Endeavour of Delphi Innovators ( Project JEDI ) }
  51. { }
  52. { You may retrieve the latest version of this file at the Project }
  53. { JEDI home page, located at http://delphi-jedi.org }
  54. { }
  55. { The contents of this file are used with permission, subject to }
  56. { the Mozilla Public License Version 1.1 (the "License"); you may }
  57. { not use this file except in compliance with the License. You may }
  58. { obtain a copy of the License at }
  59. { http://www.mozilla.org/MPL/MPL-1.1.html }
  60. { }
  61. { Software distributed under the License is distributed on an }
  62. { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
  63. { implied. See the License for the specific language governing }
  64. { rights and limitations under the License. }
  65. { }
  66. { Description }
  67. { ----------- }
  68. { }
  69. { }
  70. { }
  71. { }
  72. { }
  73. { }
  74. { }
  75. { Requires }
  76. { -------- }
  77. { The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
  78. { They are available from... }
  79. { http://www.libsdl.org . }
  80. { }
  81. { Programming Notes }
  82. { ----------------- }
  83. { }
  84. { }
  85. { }
  86. { }
  87. { Revision History }
  88. { ---------------- }
  89. { May 08 2001 - DL : Added Keyboard State Array ( See demos for how to }
  90. { use ) }
  91. { PKeyStateArr = ^TKeyStateArr; }
  92. { TKeyStateArr = array[0..65000] of UInt8; }
  93. { As most games will need it. }
  94. { }
  95. { April 02 2001 - DL : Added SDL_getenv.h definitions and tested version }
  96. { 1.2.0 compatability. }
  97. { }
  98. { March 13 2001 - MT : Added Linux compatibility. }
  99. { }
  100. { March 10 2001 - MT : Added externalsyms for DEFINES }
  101. { Changed the license header }
  102. { }
  103. { March 09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem }
  104. { }
  105. { March 01 2001 - DL : Update conversion of version 1.1.8 }
  106. { }
  107. { July 22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions }
  108. { from Matthias Thoma and Eric Grange. }
  109. { }
  110. { October 12 2001 - DL : Various changes as suggested by Matthias Thoma and }
  111. { David Acklam }
  112. { }
  113. { October 24 2001 - DL : Added FreePascal support as per suggestions from }
  114. { Dean Ellis. }
  115. { }
  116. { October 27 2001 - DL : Added SDL_BUTTON macro }
  117. { }
  118. { November 08 2001 - DL : Bug fix as pointed out by Puthoon. }
  119. { }
  120. { November 29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon}
  121. { Rushton. }
  122. { }
  123. { November 30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton. }
  124. { }
  125. { December 11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in }
  126. { Components }
  127. { }
  128. { January 05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias }
  129. { Thoma and also made sure the _getenv from }
  130. { MSVCRT.DLL uses the right calling convention }
  131. { }
  132. { January 25 2002 - DL : Updated conversion of SDL_AddTimer & }
  133. { SDL_RemoveTimer as per suggestions from Matthias }
  134. { Thoma. }
  135. { }
  136. { January 27 2002 - DL : Commented out exported function putenv and getenv }
  137. { So that developers get used to using SDL_putenv }
  138. { SDL_getenv, as they are more portable }
  139. { }
  140. { March 05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users. }
  141. { }
  142. { October 23 2002 - DL : Added Delphi 3 Define of Win32. }
  143. { If you intend to you Delphi 3... }
  144. { ( which is officially unsupported ) make sure you }
  145. { remove references to $EXTERNALSYM in this and other}
  146. { SDL files. }
  147. { }
  148. { November 29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was }
  149. { pointed out by Todd Lang }
  150. { }
  151. { April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
  152. { Pascal compilers. Initial support is now included }
  153. { for GnuPascal, VirtualPascal, TMT and obviously }
  154. { continue support for Delphi Kylix and FreePascal. }
  155. { }
  156. { April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support }
  157. { }
  158. { April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added}
  159. { better TMT Pascal support and under instruction }
  160. { from Prof. Abimbola Olowofoyeku (The African Chief),}
  161. { I have added better Gnu Pascal support }
  162. { }
  163. { April 30 2003 - DL : under instruction from David Mears AKA }
  164. { Jason Siletto, I have added FPC Linux support. }
  165. { This was compiled with fpc 1.1, so remember to set }
  166. { include file path. ie. -Fi/usr/share/fpcsrc/rtl/* }
  167. { }
  168. {
  169. $Log: sdl.pas,v $
  170. Revision 1.17 2005/01/03 18:40:59 savage
  171. Updated Version number to reflect latest one
  172. Revision 1.16 2005/01/01 02:02:06 savage
  173. Updated to v1.2.8
  174. Revision 1.15 2004/12/24 18:57:11 savage
  175. forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
  176. Revision 1.14 2004/12/23 23:42:18 savage
  177. Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
  178. Revision 1.13 2004/09/30 22:31:59 savage
  179. Updated with slightly different header comments
  180. Revision 1.12 2004/09/12 21:52:58 savage
  181. Slight changes to fix some issues with the sdl classes.
  182. Revision 1.11 2004/08/14 22:54:30 savage
  183. Updated so that Library name defines are correctly defined for MacOS X.
  184. Revision 1.10 2004/07/20 23:57:33 savage
  185. Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures.
  186. In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
  187. Revision 1.9 2004/07/03 22:07:22 savage
  188. Added Bitwise Manipulation Functions for TSDL_VideoInfo struct.
  189. Revision 1.8 2004/05/10 14:10:03 savage
  190. Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
  191. Revision 1.7 2004/04/13 09:32:08 savage
  192. Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
  193. Revision 1.6 2004/04/01 20:53:23 savage
  194. Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
  195. Revision 1.5 2004/02/22 15:32:10 savage
  196. SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out.
  197. Revision 1.4 2004/02/21 23:24:29 savage
  198. SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
  199. Revision 1.3 2004/02/18 22:35:51 savage
  200. Brought sdl.pas up to 1.2.7 compatability
  201. Thus...
  202. Added SDL_GL_STEREO,
  203. SDL_GL_MULTISAMPLEBUFFERS,
  204. SDL_GL_MULTISAMPLESAMPLES
  205. Add DLL/Shared object functions
  206. function SDL_LoadObject( const sofile : PChar ) : Pointer;
  207. function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
  208. procedure SDL_UnloadObject( handle : Pointer );
  209. Added function to create RWops from const memory: SDL_RWFromConstMem()
  210. function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
  211. Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
  212. Revision 1.2 2004/02/17 21:37:12 savage
  213. Tidying up of units
  214. Revision 1.1 2004/02/05 00:08:20 savage
  215. Module 1.0 release
  216. }
  217. {******************************************************************************}
  218. {$I jedi-sdl.inc}
  219. interface
  220. uses
  221. {$IFDEF WIN32}
  222. Windows;
  223. {$ENDIF}
  224. {$IFDEF UNIX}
  225. {$IFDEF Ver1_0}
  226. linux,
  227. {$ELSE}
  228. // pthreads,
  229. baseunix,
  230. unix,
  231. {$ENDIF}
  232. x,
  233. xlib;
  234. {$ENDIF}
  235. {$IFDEF __MACH__}
  236. GPCMacOSAll;
  237. {$ENDIF}
  238. const
  239. {$IFDEF WIN32}
  240. SDLLibName = 'SDL.dll';
  241. {$ENDIF}
  242. {$IFDEF UNIX}
  243. {$IFDEF DARWIN}
  244. SDLLibName = 'libSDL.dylib';
  245. {$ELSE}
  246. SDLLibName = 'libSDL.so';
  247. {$ENDIF}
  248. {$ENDIF}
  249. {$IFDEF MACOS}
  250. SDLLibName = 'SDL';
  251. {$ENDIF}
  252. // SDL.h constants
  253. SDL_INIT_TIMER = $00000001;
  254. {$EXTERNALSYM SDL_INIT_TIMER}
  255. SDL_INIT_AUDIO = $00000010;
  256. {$EXTERNALSYM SDL_INIT_AUDIO}
  257. SDL_INIT_VIDEO = $00000020;
  258. {$EXTERNALSYM SDL_INIT_VIDEO}
  259. SDL_INIT_CDROM = $00000100;
  260. {$EXTERNALSYM SDL_INIT_CDROM}
  261. SDL_INIT_JOYSTICK = $00000200;
  262. {$EXTERNALSYM SDL_INIT_JOYSTICK}
  263. SDL_INIT_NOPARACHUTE = $00100000; // Don't catch fatal signals
  264. {$EXTERNALSYM SDL_INIT_NOPARACHUTE}
  265. SDL_INIT_EVENTTHREAD = $01000000; // Not supported on all OS's
  266. {$EXTERNALSYM SDL_INIT_EVENTTHREAD}
  267. SDL_INIT_EVERYTHING = $0000FFFF;
  268. {$EXTERNALSYM SDL_INIT_EVERYTHING}
  269. // SDL_error.h constants
  270. ERR_MAX_STRLEN = 128;
  271. {$EXTERNALSYM ERR_MAX_STRLEN}
  272. ERR_MAX_ARGS = 5;
  273. {$EXTERNALSYM ERR_MAX_ARGS}
  274. // SDL_types.h constants
  275. SDL_PRESSED = $01;
  276. {$EXTERNALSYM SDL_PRESSED}
  277. SDL_RELEASED = $00;
  278. {$EXTERNALSYM SDL_RELEASED}
  279. // SDL_timer.h constants
  280. // This is the OS scheduler timeslice, in milliseconds
  281. SDL_TIMESLICE = 10;
  282. {$EXTERNALSYM SDL_TIMESLICE}
  283. // This is the maximum resolution of the SDL timer on all platforms
  284. TIMER_RESOLUTION = 10; // Experimentally determined
  285. {$EXTERNALSYM TIMER_RESOLUTION}
  286. // SDL_audio.h constants
  287. AUDIO_U8 = $0008; // Unsigned 8-bit samples
  288. {$EXTERNALSYM AUDIO_U8}
  289. AUDIO_S8 = $8008; // Signed 8-bit samples
  290. {$EXTERNALSYM AUDIO_S8}
  291. AUDIO_U16LSB = $0010; // Unsigned 16-bit samples
  292. {$EXTERNALSYM AUDIO_U16LSB}
  293. AUDIO_S16LSB = $8010; // Signed 16-bit samples
  294. {$EXTERNALSYM AUDIO_S16LSB}
  295. AUDIO_U16MSB = $1010; // As above, but big-endian byte order
  296. {$EXTERNALSYM AUDIO_U16MSB}
  297. AUDIO_S16MSB = $9010; // As above, but big-endian byte order
  298. {$EXTERNALSYM AUDIO_S16MSB}
  299. AUDIO_U16 = AUDIO_U16LSB;
  300. {$EXTERNALSYM AUDIO_U16}
  301. AUDIO_S16 = AUDIO_S16LSB;
  302. {$EXTERNALSYM AUDIO_S16}
  303. // SDL_cdrom.h constants
  304. // The maximum number of CD-ROM tracks on a disk
  305. SDL_MAX_TRACKS = 99;
  306. {$EXTERNALSYM SDL_MAX_TRACKS}
  307. // The types of CD-ROM track possible
  308. SDL_AUDIO_TRACK = $00;
  309. {$EXTERNALSYM SDL_AUDIO_TRACK}
  310. SDL_DATA_TRACK = $04;
  311. {$EXTERNALSYM SDL_DATA_TRACK}
  312. // Conversion functions from frames to Minute/Second/Frames and vice versa
  313. CD_FPS = 75;
  314. {$EXTERNALSYM CD_FPS}
  315. // SDL_byteorder.h constants
  316. // The two types of endianness
  317. SDL_LIL_ENDIAN = 1234;
  318. {$EXTERNALSYM SDL_LIL_ENDIAN}
  319. SDL_BIG_ENDIAN = 4321;
  320. {$EXTERNALSYM SDL_BIG_ENDIAN}
  321. {$IFDEF IA32}
  322. SDL_BYTEORDER = SDL_LIL_ENDIAN;
  323. {$EXTERNALSYM SDL_BYTEORDER}
  324. // Native audio byte ordering
  325. AUDIO_U16SYS = AUDIO_U16LSB;
  326. {$EXTERNALSYM AUDIO_U16SYS}
  327. AUDIO_S16SYS = AUDIO_S16LSB;
  328. {$EXTERNALSYM AUDIO_S16SYS}
  329. {$ELSE}
  330. SDL_BYTEORDER = SDL_BIG_ENDIAN;
  331. {$EXTERNALSYM SDL_BYTEORDER}
  332. // Native audio byte ordering
  333. AUDIO_U16SYS = AUDIO_U16MSB;
  334. {$EXTERNALSYM AUDIO_U16SYS}
  335. AUDIO_S16SYS = AUDIO_S16MSB;
  336. {$EXTERNALSYM AUDIO_S16SYS}
  337. {$ENDIF}
  338. SDL_MIX_MAXVOLUME = 128;
  339. {$EXTERNALSYM SDL_MIX_MAXVOLUME}
  340. // SDL_joystick.h constants
  341. MAX_JOYSTICKS = 2; // only 2 are supported in the multimedia API
  342. {$EXTERNALSYM MAX_JOYSTICKS}
  343. MAX_AXES = 6; // each joystick can have up to 6 axes
  344. {$EXTERNALSYM MAX_AXES}
  345. MAX_BUTTONS = 32; // and 32 buttons
  346. {$EXTERNALSYM MAX_BUTTONS}
  347. AXIS_MIN = -32768; // minimum value for axis coordinate
  348. {$EXTERNALSYM AXIS_MIN}
  349. AXIS_MAX = 32767; // maximum value for axis coordinate
  350. {$EXTERNALSYM AXIS_MAX}
  351. JOY_AXIS_THRESHOLD = (((AXIS_MAX) - (AXIS_MIN)) / 100); // 1% motion
  352. {$EXTERNALSYM JOY_AXIS_THRESHOLD}
  353. //JOY_BUTTON_FLAG(n) (1<<n)
  354. // array to hold joystick ID values
  355. //static UInt SYS_JoystickID[MAX_JOYSTICKS];
  356. //static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
  357. { Get the current state of a POV hat on a joystick
  358. The return value is one of the following positions: }
  359. SDL_HAT_CENTERED = $00;
  360. {$EXTERNALSYM SDL_HAT_CENTERED}
  361. SDL_HAT_UP = $01;
  362. {$EXTERNALSYM SDL_HAT_UP}
  363. SDL_HAT_RIGHT = $02;
  364. {$EXTERNALSYM SDL_HAT_RIGHT}
  365. SDL_HAT_DOWN = $04;
  366. {$EXTERNALSYM SDL_HAT_DOWN}
  367. SDL_HAT_LEFT = $08;
  368. {$EXTERNALSYM SDL_HAT_LEFT}
  369. SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
  370. {$EXTERNALSYM SDL_HAT_RIGHTUP}
  371. SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
  372. {$EXTERNALSYM SDL_HAT_RIGHTDOWN}
  373. SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
  374. {$EXTERNALSYM SDL_HAT_LEFTUP}
  375. SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
  376. {$EXTERNALSYM SDL_HAT_LEFTDOWN}
  377. // SDL_verion.h constants
  378. // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
  379. SDL_MAJOR_VERSION = 1;
  380. {$EXTERNALSYM SDL_MAJOR_VERSION}
  381. SDL_MINOR_VERSION = 2;
  382. {$EXTERNALSYM SDL_MINOR_VERSION}
  383. SDL_PATCHLEVEL = 8;
  384. {$EXTERNALSYM SDL_PATCHLEVEL}
  385. // SDL_events.h constants
  386. SDL_NOEVENT = 0; // Unused (do not remove)
  387. {$EXTERNALSYM SDL_NOEVENT}
  388. SDL_ACTIVEEVENT = 1; // Application loses/gains visibility
  389. {$EXTERNALSYM SDL_ACTIVEEVENT}
  390. SDL_KEYDOWN = 2; // Keys pressed
  391. {$EXTERNALSYM SDL_KEYDOWN}
  392. SDL_KEYUP = 3; // Keys released
  393. {$EXTERNALSYM SDL_KEYUP}
  394. SDL_MOUSEMOTION = 4; // Mouse moved
  395. {$EXTERNALSYM SDL_MOUSEMOTION}
  396. SDL_MOUSEBUTTONDOWN = 5; // Mouse button pressed
  397. {$EXTERNALSYM SDL_MOUSEBUTTONDOWN}
  398. SDL_MOUSEBUTTONUP = 6; // Mouse button released
  399. {$EXTERNALSYM SDL_MOUSEBUTTONUP}
  400. SDL_JOYAXISMOTION = 7; // Joystick axis motion
  401. {$EXTERNALSYM SDL_JOYAXISMOTION}
  402. SDL_JOYBALLMOTION = 8; // Joystick trackball motion
  403. {$EXTERNALSYM SDL_JOYBALLMOTION}
  404. SDL_JOYHATMOTION = 9; // Joystick hat position change
  405. {$EXTERNALSYM SDL_JOYHATMOTION}
  406. SDL_JOYBUTTONDOWN = 10; // Joystick button pressed
  407. {$EXTERNALSYM SDL_JOYBUTTONDOWN}
  408. SDL_JOYBUTTONUP = 11; // Joystick button released
  409. {$EXTERNALSYM SDL_JOYBUTTONUP}
  410. SDL_QUITEV = 12; // User-requested quit ( Changed due to procedure conflict )
  411. {$EXTERNALSYM SDL_QUIT}
  412. SDL_SYSWMEVENT = 13; // System specific event
  413. {$EXTERNALSYM SDL_SYSWMEVENT}
  414. SDL_EVENT_RESERVEDA = 14; // Reserved for future use..
  415. {$EXTERNALSYM SDL_EVENT_RESERVEDA}
  416. SDL_EVENT_RESERVED = 15; // Reserved for future use..
  417. {$EXTERNALSYM SDL_EVENT_RESERVED}
  418. SDL_VIDEORESIZE = 16; // User resized video mode
  419. {$EXTERNALSYM SDL_VIDEORESIZE}
  420. SDL_VIDEOEXPOSE = 17; // Screen needs to be redrawn
  421. {$EXTERNALSYM SDL_VIDEOEXPOSE}
  422. SDL_EVENT_RESERVED2 = 18; // Reserved for future use..
  423. {$EXTERNALSYM SDL_EVENT_RESERVED2}
  424. SDL_EVENT_RESERVED3 = 19; // Reserved for future use..
  425. {$EXTERNALSYM SDL_EVENT_RESERVED3}
  426. SDL_EVENT_RESERVED4 = 20; // Reserved for future use..
  427. {$EXTERNALSYM SDL_EVENT_RESERVED4}
  428. SDL_EVENT_RESERVED5 = 21; // Reserved for future use..
  429. {$EXTERNALSYM SDL_EVENT_RESERVED5}
  430. SDL_EVENT_RESERVED6 = 22; // Reserved for future use..
  431. {$EXTERNALSYM SDL_EVENT_RESERVED6}
  432. SDL_EVENT_RESERVED7 = 23; // Reserved for future use..
  433. {$EXTERNALSYM SDL_EVENT_RESERVED7}
  434. // Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
  435. SDL_USEREVENT = 24;
  436. {$EXTERNALSYM SDL_USEREVENT}
  437. // This last event is only for bounding internal arrays
  438. // It is the number of bits in the event mask datatype -- UInt32
  439. SDL_NUMEVENTS = 32;
  440. {$EXTERNALSYM SDL_NUMEVENTS}
  441. SDL_ALLEVENTS = $FFFFFFFF;
  442. {$EXTERNALSYM SDL_ALLEVENTS}
  443. SDL_ACTIVEEVENTMASK = 1 shl SDL_ACTIVEEVENT;
  444. {$EXTERNALSYM SDL_ACTIVEEVENTMASK}
  445. SDL_KEYDOWNMASK = 1 shl SDL_KEYDOWN;
  446. {$EXTERNALSYM SDL_KEYDOWNMASK}
  447. SDL_KEYUPMASK = 1 shl SDL_KEYUP;
  448. {$EXTERNALSYM SDL_KEYUPMASK}
  449. SDL_MOUSEMOTIONMASK = 1 shl SDL_MOUSEMOTION;
  450. {$EXTERNALSYM SDL_MOUSEMOTIONMASK}
  451. SDL_MOUSEBUTTONDOWNMASK = 1 shl SDL_MOUSEBUTTONDOWN;
  452. {$EXTERNALSYM SDL_MOUSEBUTTONDOWNMASK}
  453. SDL_MOUSEBUTTONUPMASK = 1 shl SDL_MOUSEBUTTONUP;
  454. {$EXTERNALSYM SDL_MOUSEBUTTONUPMASK}
  455. SDL_MOUSEEVENTMASK = 1 shl SDL_MOUSEMOTION or
  456. 1 shl SDL_MOUSEBUTTONDOWN or
  457. 1 shl SDL_MOUSEBUTTONUP;
  458. {$EXTERNALSYM SDL_MOUSEEVENTMASK}
  459. SDL_JOYAXISMOTIONMASK = 1 shl SDL_JOYAXISMOTION;
  460. {$EXTERNALSYM SDL_JOYAXISMOTIONMASK}
  461. SDL_JOYBALLMOTIONMASK = 1 shl SDL_JOYBALLMOTION;
  462. {$EXTERNALSYM SDL_JOYBALLMOTIONMASK}
  463. SDL_JOYHATMOTIONMASK = 1 shl SDL_JOYHATMOTION;
  464. {$EXTERNALSYM SDL_JOYHATMOTIONMASK}
  465. SDL_JOYBUTTONDOWNMASK = 1 shl SDL_JOYBUTTONDOWN;
  466. {$EXTERNALSYM SDL_JOYBUTTONDOWNMASK}
  467. SDL_JOYBUTTONUPMASK = 1 shl SDL_JOYBUTTONUP;
  468. {$EXTERNALSYM SDL_JOYBUTTONUPMASK}
  469. SDL_JOYEVENTMASK = 1 shl SDL_JOYAXISMOTION or
  470. 1 shl SDL_JOYBALLMOTION or
  471. 1 shl SDL_JOYHATMOTION or
  472. 1 shl SDL_JOYBUTTONDOWN or
  473. 1 shl SDL_JOYBUTTONUP;
  474. {$EXTERNALSYM SDL_JOYEVENTMASK}
  475. SDL_VIDEORESIZEMASK = 1 shl SDL_VIDEORESIZE;
  476. {$EXTERNALSYM SDL_VIDEORESIZEMASK}
  477. SDL_QUITMASK = 1 shl SDL_QUITEV;
  478. {$EXTERNALSYM SDL_QUITMASK}
  479. SDL_SYSWMEVENTMASK = 1 shl SDL_SYSWMEVENT;
  480. {$EXTERNALSYM SDL_SYSWMEVENTMASK}
  481. { This function allows you to set the state of processing certain events.
  482. If 'state' is set to SDL_IGNORE, that event will be automatically dropped
  483. from the event queue and will not event be filtered.
  484. If 'state' is set to SDL_ENABLE, that event will be processed normally.
  485. If 'state' is set to SDL_QUERY, SDL_EventState() will return the
  486. current processing state of the specified event. }
  487. SDL_QUERY = -1;
  488. {$EXTERNALSYM SDL_QUERY}
  489. SDL_IGNORE = 0;
  490. {$EXTERNALSYM SDL_IGNORE}
  491. SDL_DISABLE = 0;
  492. {$EXTERNALSYM SDL_DISABLE}
  493. SDL_ENABLE = 1;
  494. {$EXTERNALSYM SDL_ENABLE}
  495. //SDL_keyboard.h constants
  496. // This is the mask which refers to all hotkey bindings
  497. SDL_ALL_HOTKEYS = $FFFFFFFF;
  498. {$EXTERNALSYM SDL_ALL_HOTKEYS}
  499. { Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
  500. 'delay' is the initial delay in ms between the time when a key is
  501. pressed, and keyboard repeat begins.
  502. 'interval' is the time in ms between keyboard repeat events. }
  503. SDL_DEFAULT_REPEAT_DELAY = 500;
  504. {$EXTERNALSYM SDL_DEFAULT_REPEAT_DELAY}
  505. SDL_DEFAULT_REPEAT_INTERVAL = 30;
  506. {$EXTERNALSYM SDL_DEFAULT_REPEAT_INTERVAL}
  507. // The keyboard syms have been cleverly chosen to map to ASCII
  508. SDLK_UNKNOWN = 0;
  509. {$EXTERNALSYM SDLK_UNKNOWN}
  510. SDLK_FIRST = 0;
  511. {$EXTERNALSYM SDLK_FIRST}
  512. SDLK_BACKSPACE = 8;
  513. {$EXTERNALSYM SDLK_BACKSPACE}
  514. SDLK_TAB = 9;
  515. {$EXTERNALSYM SDLK_TAB}
  516. SDLK_CLEAR = 12;
  517. {$EXTERNALSYM SDLK_CLEAR}
  518. SDLK_RETURN = 13;
  519. {$EXTERNALSYM SDLK_RETURN}
  520. SDLK_PAUSE = 19;
  521. {$EXTERNALSYM SDLK_PAUSE}
  522. SDLK_ESCAPE = 27;
  523. {$EXTERNALSYM SDLK_ESCAPE}
  524. SDLK_SPACE = 32;
  525. {$EXTERNALSYM SDLK_SPACE}
  526. SDLK_EXCLAIM = 33;
  527. {$EXTERNALSYM SDLK_EXCLAIM}
  528. SDLK_QUOTEDBL = 34;
  529. {$EXTERNALSYM SDLK_QUOTEDBL}
  530. SDLK_HASH = 35;
  531. {$EXTERNALSYM SDLK_HASH}
  532. SDLK_DOLLAR = 36;
  533. {$EXTERNALSYM SDLK_DOLLAR}
  534. SDLK_AMPERSAND = 38;
  535. {$EXTERNALSYM SDLK_AMPERSAND}
  536. SDLK_QUOTE = 39;
  537. {$EXTERNALSYM SDLK_QUOTE}
  538. SDLK_LEFTPAREN = 40;
  539. {$EXTERNALSYM SDLK_LEFTPAREN}
  540. SDLK_RIGHTPAREN = 41;
  541. {$EXTERNALSYM SDLK_RIGHTPAREN}
  542. SDLK_ASTERISK = 42;
  543. {$EXTERNALSYM SDLK_ASTERISK}
  544. SDLK_PLUS = 43;
  545. {$EXTERNALSYM SDLK_PLUS}
  546. SDLK_COMMA = 44;
  547. {$EXTERNALSYM SDLK_COMMA}
  548. SDLK_MINUS = 45;
  549. {$EXTERNALSYM SDLK_MINUS}
  550. SDLK_PERIOD = 46;
  551. {$EXTERNALSYM SDLK_PERIOD}
  552. SDLK_SLASH = 47;
  553. {$EXTERNALSYM SDLK_SLASH}
  554. SDLK_0 = 48;
  555. {$EXTERNALSYM SDLK_0}
  556. SDLK_1 = 49;
  557. {$EXTERNALSYM SDLK_1}
  558. SDLK_2 = 50;
  559. {$EXTERNALSYM SDLK_2}
  560. SDLK_3 = 51;
  561. {$EXTERNALSYM SDLK_3}
  562. SDLK_4 = 52;
  563. {$EXTERNALSYM SDLK_4}
  564. SDLK_5 = 53;
  565. {$EXTERNALSYM SDLK_5}
  566. SDLK_6 = 54;
  567. {$EXTERNALSYM SDLK_6}
  568. SDLK_7 = 55;
  569. {$EXTERNALSYM SDLK_7}
  570. SDLK_8 = 56;
  571. {$EXTERNALSYM SDLK_8}
  572. SDLK_9 = 57;
  573. {$EXTERNALSYM SDLK_9}
  574. SDLK_COLON = 58;
  575. {$EXTERNALSYM SDLK_COLON}
  576. SDLK_SEMICOLON = 59;
  577. {$EXTERNALSYM SDLK_SEMICOLON}
  578. SDLK_LESS = 60;
  579. {$EXTERNALSYM SDLK_LESS}
  580. SDLK_EQUALS = 61;
  581. {$EXTERNALSYM SDLK_EQUALS}
  582. SDLK_GREATER = 62;
  583. {$EXTERNALSYM SDLK_GREATER}
  584. SDLK_QUESTION = 63;
  585. {$EXTERNALSYM SDLK_QUESTION}
  586. SDLK_AT = 64;
  587. {$EXTERNALSYM SDLK_AT}
  588. { Skip uppercase letters }
  589. SDLK_LEFTBRACKET = 91;
  590. {$EXTERNALSYM SDLK_LEFTBRACKET}
  591. SDLK_BACKSLASH = 92;
  592. {$EXTERNALSYM SDLK_BACKSLASH}
  593. SDLK_RIGHTBRACKET = 93;
  594. {$EXTERNALSYM SDLK_RIGHTBRACKET}
  595. SDLK_CARET = 94;
  596. {$EXTERNALSYM SDLK_CARET}
  597. SDLK_UNDERSCORE = 95;
  598. {$EXTERNALSYM SDLK_UNDERSCORE}
  599. SDLK_BACKQUOTE = 96;
  600. {$EXTERNALSYM SDLK_BACKQUOTE}
  601. SDLK_a = 97;
  602. {$EXTERNALSYM SDLK_a}
  603. SDLK_b = 98;
  604. {$EXTERNALSYM SDLK_b}
  605. SDLK_c = 99;
  606. {$EXTERNALSYM SDLK_c}
  607. SDLK_d = 100;
  608. {$EXTERNALSYM SDLK_d}
  609. SDLK_e = 101;
  610. {$EXTERNALSYM SDLK_e}
  611. SDLK_f = 102;
  612. {$EXTERNALSYM SDLK_f}
  613. SDLK_g = 103;
  614. {$EXTERNALSYM SDLK_g}
  615. SDLK_h = 104;
  616. {$EXTERNALSYM SDLK_h}
  617. SDLK_i = 105;
  618. {$EXTERNALSYM SDLK_i}
  619. SDLK_j = 106;
  620. {$EXTERNALSYM SDLK_j}
  621. SDLK_k = 107;
  622. {$EXTERNALSYM SDLK_k}
  623. SDLK_l = 108;
  624. {$EXTERNALSYM SDLK_l}
  625. SDLK_m = 109;
  626. {$EXTERNALSYM SDLK_m}
  627. SDLK_n = 110;
  628. {$EXTERNALSYM SDLK_n}
  629. SDLK_o = 111;
  630. {$EXTERNALSYM SDLK_o}
  631. SDLK_p = 112;
  632. {$EXTERNALSYM SDLK_p}
  633. SDLK_q = 113;
  634. {$EXTERNALSYM SDLK_q}
  635. SDLK_r = 114;
  636. {$EXTERNALSYM SDLK_r}
  637. SDLK_s = 115;
  638. {$EXTERNALSYM SDLK_s}
  639. SDLK_t = 116;
  640. {$EXTERNALSYM SDLK_t}
  641. SDLK_u = 117;
  642. {$EXTERNALSYM SDLK_u}
  643. SDLK_v = 118;
  644. {$EXTERNALSYM SDLK_v}
  645. SDLK_w = 119;
  646. {$EXTERNALSYM SDLK_w}
  647. SDLK_x = 120;
  648. {$EXTERNALSYM SDLK_x}
  649. SDLK_y = 121;
  650. {$EXTERNALSYM SDLK_y}
  651. SDLK_z = 122;
  652. {$EXTERNALSYM SDLK_z}
  653. SDLK_DELETE = 127;
  654. {$EXTERNALSYM SDLK_DELETE}
  655. // End of ASCII mapped keysyms
  656. // International keyboard syms
  657. SDLK_WORLD_0 = 160; // 0xA0
  658. {$EXTERNALSYM SDLK_WORLD_0}
  659. SDLK_WORLD_1 = 161;
  660. {$EXTERNALSYM SDLK_WORLD_1}
  661. SDLK_WORLD_2 = 162;
  662. {$EXTERNALSYM SDLK_WORLD_2}
  663. SDLK_WORLD_3 = 163;
  664. {$EXTERNALSYM SDLK_WORLD_3}
  665. SDLK_WORLD_4 = 164;
  666. {$EXTERNALSYM SDLK_WORLD_4}
  667. SDLK_WORLD_5 = 165;
  668. {$EXTERNALSYM SDLK_WORLD_5}
  669. SDLK_WORLD_6 = 166;
  670. {$EXTERNALSYM SDLK_WORLD_6}
  671. SDLK_WORLD_7 = 167;
  672. {$EXTERNALSYM SDLK_WORLD_7}
  673. SDLK_WORLD_8 = 168;
  674. {$EXTERNALSYM SDLK_WORLD_8}
  675. SDLK_WORLD_9 = 169;
  676. {$EXTERNALSYM SDLK_WORLD_9}
  677. SDLK_WORLD_10 = 170;
  678. {$EXTERNALSYM SDLK_WORLD_10}
  679. SDLK_WORLD_11 = 171;
  680. {$EXTERNALSYM SDLK_WORLD_11}
  681. SDLK_WORLD_12 = 172;
  682. {$EXTERNALSYM SDLK_WORLD_12}
  683. SDLK_WORLD_13 = 173;
  684. {$EXTERNALSYM SDLK_WORLD_13}
  685. SDLK_WORLD_14 = 174;
  686. {$EXTERNALSYM SDLK_WORLD_14}
  687. SDLK_WORLD_15 = 175;
  688. {$EXTERNALSYM SDLK_WORLD_15}
  689. SDLK_WORLD_16 = 176;
  690. {$EXTERNALSYM SDLK_WORLD_16}
  691. SDLK_WORLD_17 = 177;
  692. {$EXTERNALSYM SDLK_WORLD_17}
  693. SDLK_WORLD_18 = 178;
  694. {$EXTERNALSYM SDLK_WORLD_18}
  695. SDLK_WORLD_19 = 179;
  696. {$EXTERNALSYM SDLK_WORLD_19}
  697. SDLK_WORLD_20 = 180;
  698. {$EXTERNALSYM SDLK_WORLD_20}
  699. SDLK_WORLD_21 = 181;
  700. {$EXTERNALSYM SDLK_WORLD_21}
  701. SDLK_WORLD_22 = 182;
  702. {$EXTERNALSYM SDLK_WORLD_22}
  703. SDLK_WORLD_23 = 183;
  704. {$EXTERNALSYM SDLK_WORLD_23}
  705. SDLK_WORLD_24 = 184;
  706. {$EXTERNALSYM SDLK_WORLD_24}
  707. SDLK_WORLD_25 = 185;
  708. {$EXTERNALSYM SDLK_WORLD_25}
  709. SDLK_WORLD_26 = 186;
  710. {$EXTERNALSYM SDLK_WORLD_26}
  711. SDLK_WORLD_27 = 187;
  712. {$EXTERNALSYM SDLK_WORLD_27}
  713. SDLK_WORLD_28 = 188;
  714. {$EXTERNALSYM SDLK_WORLD_28}
  715. SDLK_WORLD_29 = 189;
  716. {$EXTERNALSYM SDLK_WORLD_29}
  717. SDLK_WORLD_30 = 190;
  718. {$EXTERNALSYM SDLK_WORLD_30}
  719. SDLK_WORLD_31 = 191;
  720. {$EXTERNALSYM SDLK_WORLD_31}
  721. SDLK_WORLD_32 = 192;
  722. {$EXTERNALSYM SDLK_WORLD_32}
  723. SDLK_WORLD_33 = 193;
  724. {$EXTERNALSYM SDLK_WORLD_33}
  725. SDLK_WORLD_34 = 194;
  726. {$EXTERNALSYM SDLK_WORLD_34}
  727. SDLK_WORLD_35 = 195;
  728. {$EXTERNALSYM SDLK_WORLD_35}
  729. SDLK_WORLD_36 = 196;
  730. {$EXTERNALSYM SDLK_WORLD_36}
  731. SDLK_WORLD_37 = 197;
  732. {$EXTERNALSYM SDLK_WORLD_37}
  733. SDLK_WORLD_38 = 198;
  734. {$EXTERNALSYM SDLK_WORLD_38}
  735. SDLK_WORLD_39 = 199;
  736. {$EXTERNALSYM SDLK_WORLD_39}
  737. SDLK_WORLD_40 = 200;
  738. {$EXTERNALSYM SDLK_WORLD_40}
  739. SDLK_WORLD_41 = 201;
  740. {$EXTERNALSYM SDLK_WORLD_41}
  741. SDLK_WORLD_42 = 202;
  742. {$EXTERNALSYM SDLK_WORLD_42}
  743. SDLK_WORLD_43 = 203;
  744. {$EXTERNALSYM SDLK_WORLD_43}
  745. SDLK_WORLD_44 = 204;
  746. {$EXTERNALSYM SDLK_WORLD_44}
  747. SDLK_WORLD_45 = 205;
  748. {$EXTERNALSYM SDLK_WORLD_45}
  749. SDLK_WORLD_46 = 206;
  750. {$EXTERNALSYM SDLK_WORLD_46}
  751. SDLK_WORLD_47 = 207;
  752. {$EXTERNALSYM SDLK_WORLD_47}
  753. SDLK_WORLD_48 = 208;
  754. {$EXTERNALSYM SDLK_WORLD_48}
  755. SDLK_WORLD_49 = 209;
  756. {$EXTERNALSYM SDLK_WORLD_49}
  757. SDLK_WORLD_50 = 210;
  758. {$EXTERNALSYM SDLK_WORLD_50}
  759. SDLK_WORLD_51 = 211;
  760. {$EXTERNALSYM SDLK_WORLD_51}
  761. SDLK_WORLD_52 = 212;
  762. {$EXTERNALSYM SDLK_WORLD_52}
  763. SDLK_WORLD_53 = 213;
  764. {$EXTERNALSYM SDLK_WORLD_53}
  765. SDLK_WORLD_54 = 214;
  766. {$EXTERNALSYM SDLK_WORLD_54}
  767. SDLK_WORLD_55 = 215;
  768. {$EXTERNALSYM SDLK_WORLD_55}
  769. SDLK_WORLD_56 = 216;
  770. {$EXTERNALSYM SDLK_WORLD_56}
  771. SDLK_WORLD_57 = 217;
  772. {$EXTERNALSYM SDLK_WORLD_57}
  773. SDLK_WORLD_58 = 218;
  774. {$EXTERNALSYM SDLK_WORLD_58}
  775. SDLK_WORLD_59 = 219;
  776. {$EXTERNALSYM SDLK_WORLD_59}
  777. SDLK_WORLD_60 = 220;
  778. {$EXTERNALSYM SDLK_WORLD_60}
  779. SDLK_WORLD_61 = 221;
  780. {$EXTERNALSYM SDLK_WORLD_61}
  781. SDLK_WORLD_62 = 222;
  782. {$EXTERNALSYM SDLK_WORLD_62}
  783. SDLK_WORLD_63 = 223;
  784. {$EXTERNALSYM SDLK_WORLD_63}
  785. SDLK_WORLD_64 = 224;
  786. {$EXTERNALSYM SDLK_WORLD_64}
  787. SDLK_WORLD_65 = 225;
  788. {$EXTERNALSYM SDLK_WORLD_65}
  789. SDLK_WORLD_66 = 226;
  790. {$EXTERNALSYM SDLK_WORLD_66}
  791. SDLK_WORLD_67 = 227;
  792. {$EXTERNALSYM SDLK_WORLD_67}
  793. SDLK_WORLD_68 = 228;
  794. {$EXTERNALSYM SDLK_WORLD_68}
  795. SDLK_WORLD_69 = 229;
  796. {$EXTERNALSYM SDLK_WORLD_69}
  797. SDLK_WORLD_70 = 230;
  798. {$EXTERNALSYM SDLK_WORLD_70}
  799. SDLK_WORLD_71 = 231;
  800. {$EXTERNALSYM SDLK_WORLD_71}
  801. SDLK_WORLD_72 = 232;
  802. {$EXTERNALSYM SDLK_WORLD_72}
  803. SDLK_WORLD_73 = 233;
  804. {$EXTERNALSYM SDLK_WORLD_73}
  805. SDLK_WORLD_74 = 234;
  806. {$EXTERNALSYM SDLK_WORLD_74}
  807. SDLK_WORLD_75 = 235;
  808. {$EXTERNALSYM SDLK_WORLD_75}
  809. SDLK_WORLD_76 = 236;
  810. {$EXTERNALSYM SDLK_WORLD_76}
  811. SDLK_WORLD_77 = 237;
  812. {$EXTERNALSYM SDLK_WORLD_77}
  813. SDLK_WORLD_78 = 238;
  814. {$EXTERNALSYM SDLK_WORLD_78}
  815. SDLK_WORLD_79 = 239;
  816. {$EXTERNALSYM SDLK_WORLD_79}
  817. SDLK_WORLD_80 = 240;
  818. {$EXTERNALSYM SDLK_WORLD_80}
  819. SDLK_WORLD_81 = 241;
  820. {$EXTERNALSYM SDLK_WORLD_81}
  821. SDLK_WORLD_82 = 242;
  822. {$EXTERNALSYM SDLK_WORLD_82}
  823. SDLK_WORLD_83 = 243;
  824. {$EXTERNALSYM SDLK_WORLD_83}
  825. SDLK_WORLD_84 = 244;
  826. {$EXTERNALSYM SDLK_WORLD_84}
  827. SDLK_WORLD_85 = 245;
  828. {$EXTERNALSYM SDLK_WORLD_85}
  829. SDLK_WORLD_86 = 246;
  830. {$EXTERNALSYM SDLK_WORLD_86}
  831. SDLK_WORLD_87 = 247;
  832. {$EXTERNALSYM SDLK_WORLD_87}
  833. SDLK_WORLD_88 = 248;
  834. {$EXTERNALSYM SDLK_WORLD_88}
  835. SDLK_WORLD_89 = 249;
  836. {$EXTERNALSYM SDLK_WORLD_89}
  837. SDLK_WORLD_90 = 250;
  838. {$EXTERNALSYM SDLK_WORLD_90}
  839. SDLK_WORLD_91 = 251;
  840. {$EXTERNALSYM SDLK_WORLD_91}
  841. SDLK_WORLD_92 = 252;
  842. {$EXTERNALSYM SDLK_WORLD_92}
  843. SDLK_WORLD_93 = 253;
  844. {$EXTERNALSYM SDLK_WORLD_93}
  845. SDLK_WORLD_94 = 254;
  846. {$EXTERNALSYM SDLK_WORLD_94}
  847. SDLK_WORLD_95 = 255; // 0xFF
  848. {$EXTERNALSYM SDLK_WORLD_95}
  849. // Numeric keypad
  850. SDLK_KP0 = 256;
  851. {$EXTERNALSYM SDLK_KP0}
  852. SDLK_KP1 = 257;
  853. {$EXTERNALSYM SDLK_KP1}
  854. SDLK_KP2 = 258;
  855. {$EXTERNALSYM SDLK_KP2}
  856. SDLK_KP3 = 259;
  857. {$EXTERNALSYM SDLK_KP3}
  858. SDLK_KP4 = 260;
  859. {$EXTERNALSYM SDLK_KP4}
  860. SDLK_KP5 = 261;
  861. {$EXTERNALSYM SDLK_KP5}
  862. SDLK_KP6 = 262;
  863. {$EXTERNALSYM SDLK_KP6}
  864. SDLK_KP7 = 263;
  865. {$EXTERNALSYM SDLK_KP7}
  866. SDLK_KP8 = 264;
  867. {$EXTERNALSYM SDLK_KP8}
  868. SDLK_KP9 = 265;
  869. {$EXTERNALSYM SDLK_KP9}
  870. SDLK_KP_PERIOD = 266;
  871. {$EXTERNALSYM SDLK_KP_PERIOD}
  872. SDLK_KP_DIVIDE = 267;
  873. {$EXTERNALSYM SDLK_KP_DIVIDE}
  874. SDLK_KP_MULTIPLY = 268;
  875. {$EXTERNALSYM SDLK_KP_MULTIPLY}
  876. SDLK_KP_MINUS = 269;
  877. {$EXTERNALSYM SDLK_KP_MINUS}
  878. SDLK_KP_PLUS = 270;
  879. {$EXTERNALSYM SDLK_KP_PLUS}
  880. SDLK_KP_ENTER = 271;
  881. {$EXTERNALSYM SDLK_KP_ENTER}
  882. SDLK_KP_EQUALS = 272;
  883. {$EXTERNALSYM SDLK_KP_EQUALS}
  884. // Arrows + Home/End pad
  885. SDLK_UP = 273;
  886. {$EXTERNALSYM SDLK_UP}
  887. SDLK_DOWN = 274;
  888. {$EXTERNALSYM SDLK_DOWN}
  889. SDLK_RIGHT = 275;
  890. {$EXTERNALSYM SDLK_RIGHT}
  891. SDLK_LEFT = 276;
  892. {$EXTERNALSYM SDLK_LEFT}
  893. SDLK_INSERT = 277;
  894. {$EXTERNALSYM SDLK_INSERT}
  895. SDLK_HOME = 278;
  896. {$EXTERNALSYM SDLK_HOME}
  897. SDLK_END = 279;
  898. {$EXTERNALSYM SDLK_END}
  899. SDLK_PAGEUP = 280;
  900. {$EXTERNALSYM SDLK_PAGEUP}
  901. SDLK_PAGEDOWN = 281;
  902. {$EXTERNALSYM SDLK_PAGEDOWN}
  903. // Function keys
  904. SDLK_F1 = 282;
  905. {$EXTERNALSYM SDLK_F1}
  906. SDLK_F2 = 283;
  907. {$EXTERNALSYM SDLK_F2}
  908. SDLK_F3 = 284;
  909. {$EXTERNALSYM SDLK_F3}
  910. SDLK_F4 = 285;
  911. {$EXTERNALSYM SDLK_F4}
  912. SDLK_F5 = 286;
  913. {$EXTERNALSYM SDLK_F5}
  914. SDLK_F6 = 287;
  915. {$EXTERNALSYM SDLK_F6}
  916. SDLK_F7 = 288;
  917. {$EXTERNALSYM SDLK_F7}
  918. SDLK_F8 = 289;
  919. {$EXTERNALSYM SDLK_F8}
  920. SDLK_F9 = 290;
  921. {$EXTERNALSYM SDLK_F9}
  922. SDLK_F10 = 291;
  923. {$EXTERNALSYM SDLK_F10}
  924. SDLK_F11 = 292;
  925. {$EXTERNALSYM SDLK_F11}
  926. SDLK_F12 = 293;
  927. {$EXTERNALSYM SDLK_F12}
  928. SDLK_F13 = 294;
  929. {$EXTERNALSYM SDLK_F13}
  930. SDLK_F14 = 295;
  931. {$EXTERNALSYM SDLK_F14}
  932. SDLK_F15 = 296;
  933. {$EXTERNALSYM SDLK_F15}
  934. // Key state modifier keys
  935. SDLK_NUMLOCK = 300;
  936. {$EXTERNALSYM SDLK_NUMLOCK}
  937. SDLK_CAPSLOCK = 301;
  938. {$EXTERNALSYM SDLK_CAPSLOCK}
  939. SDLK_SCROLLOCK = 302;
  940. {$EXTERNALSYM SDLK_SCROLLOCK}
  941. SDLK_RSHIFT = 303;
  942. {$EXTERNALSYM SDLK_RSHIFT}
  943. SDLK_LSHIFT = 304;
  944. {$EXTERNALSYM SDLK_LSHIFT}
  945. SDLK_RCTRL = 305;
  946. {$EXTERNALSYM SDLK_RCTRL}
  947. SDLK_LCTRL = 306;
  948. {$EXTERNALSYM SDLK_LCTRL}
  949. SDLK_RALT = 307;
  950. {$EXTERNALSYM SDLK_RALT}
  951. SDLK_LALT = 308;
  952. {$EXTERNALSYM SDLK_LALT}
  953. SDLK_RMETA = 309;
  954. {$EXTERNALSYM SDLK_RMETA}
  955. SDLK_LMETA = 310;
  956. {$EXTERNALSYM SDLK_LMETA}
  957. SDLK_LSUPER = 311; // Left "Windows" key
  958. {$EXTERNALSYM SDLK_LSUPER}
  959. SDLK_RSUPER = 312; // Right "Windows" key
  960. {$EXTERNALSYM SDLK_RSUPER}
  961. SDLK_MODE = 313; // "Alt Gr" key
  962. {$EXTERNALSYM SDLK_MODE}
  963. SDLK_COMPOSE = 314; // Multi-key compose key
  964. {$EXTERNALSYM SDLK_COMPOSE}
  965. // Miscellaneous function keys
  966. SDLK_HELP = 315;
  967. {$EXTERNALSYM SDLK_HELP}
  968. SDLK_PRINT = 316;
  969. {$EXTERNALSYM SDLK_PRINT}
  970. SDLK_SYSREQ = 317;
  971. {$EXTERNALSYM SDLK_SYSREQ}
  972. SDLK_BREAK = 318;
  973. {$EXTERNALSYM SDLK_BREAK}
  974. SDLK_MENU = 319;
  975. {$EXTERNALSYM SDLK_MENU}
  976. SDLK_POWER = 320; // Power Macintosh power key
  977. {$EXTERNALSYM SDLK_POWER}
  978. SDLK_EURO = 321; // Some european keyboards
  979. {$EXTERNALSYM SDLK_EURO}
  980. // Enumeration of valid key mods (possibly OR'd together)
  981. KMOD_NONE = $0000;
  982. {$EXTERNALSYM KMOD_NONE}
  983. KMOD_LSHIFT = $0001;
  984. {$EXTERNALSYM KMOD_LSHIFT}
  985. KMOD_RSHIFT = $0002;
  986. {$EXTERNALSYM KMOD_RSHIFT}
  987. KMOD_LCTRL = $0040;
  988. {$EXTERNALSYM KMOD_LCTRL}
  989. KMOD_RCTRL = $0080;
  990. {$EXTERNALSYM KMOD_RCTRL}
  991. KMOD_LALT = $0100;
  992. {$EXTERNALSYM KMOD_LALT}
  993. KMOD_RALT = $0200;
  994. {$EXTERNALSYM KMOD_RALT}
  995. KMOD_LMETA = $0400;
  996. {$EXTERNALSYM KMOD_LMETA}
  997. KMOD_RMETA = $0800;
  998. {$EXTERNALSYM KMOD_RMETA}
  999. KMOD_NUM = $1000;
  1000. {$EXTERNALSYM KMOD_NUM}
  1001. KMOD_CAPS = $2000;
  1002. {$EXTERNALSYM KMOD_CAPS}
  1003. KMOD_MODE = 44000;
  1004. {$EXTERNALSYM KMOD_MODE}
  1005. KMOD_RESERVED = $8000;
  1006. {$EXTERNALSYM KMOD_RESERVED}
  1007. KMOD_CTRL = (KMOD_LCTRL or KMOD_RCTRL);
  1008. {$EXTERNALSYM KMOD_CTRL}
  1009. KMOD_SHIFT = (KMOD_LSHIFT or KMOD_RSHIFT);
  1010. {$EXTERNALSYM KMOD_SHIFT}
  1011. KMOD_ALT = (KMOD_LALT or KMOD_RALT);
  1012. {$EXTERNALSYM KMOD_ALT}
  1013. KMOD_META = (KMOD_LMETA or KMOD_RMETA);
  1014. {$EXTERNALSYM KMOD_META}
  1015. //SDL_video.h constants
  1016. // Transparency definitions: These define alpha as the opacity of a surface */
  1017. SDL_ALPHA_OPAQUE = 255;
  1018. {$EXTERNALSYM SDL_ALPHA_OPAQUE}
  1019. SDL_ALPHA_TRANSPARENT = 0;
  1020. {$EXTERNALSYM SDL_ALPHA_TRANSPARENT}
  1021. // These are the currently supported flags for the SDL_surface
  1022. // Available for SDL_CreateRGBSurface() or SDL_SetVideoMode()
  1023. SDL_SWSURFACE = $00000000; // Surface is in system memory
  1024. {$EXTERNALSYM SDL_SWSURFACE}
  1025. SDL_HWSURFACE = $00000001; // Surface is in video memory
  1026. {$EXTERNALSYM SDL_HWSURFACE}
  1027. SDL_ASYNCBLIT = $00000004; // Use asynchronous blits if possible
  1028. {$EXTERNALSYM SDL_ASYNCBLIT}
  1029. // Available for SDL_SetVideoMode()
  1030. SDL_ANYFORMAT = $10000000; // Allow any video depth/pixel-format
  1031. {$EXTERNALSYM SDL_ANYFORMAT}
  1032. SDL_HWPALETTE = $20000000; // Surface has exclusive palette
  1033. {$EXTERNALSYM SDL_HWPALETTE}
  1034. SDL_DOUBLEBUF = $40000000; // Set up double-buffered video mode
  1035. {$EXTERNALSYM SDL_DOUBLEBUF}
  1036. SDL_FULLSCREEN = $80000000; // Surface is a full screen display
  1037. {$EXTERNALSYM SDL_FULLSCREEN}
  1038. SDL_OPENGL = $00000002; // Create an OpenGL rendering context
  1039. {$EXTERNALSYM SDL_OPENGL}
  1040. SDL_OPENGLBLIT = $00000002; // Create an OpenGL rendering context
  1041. {$EXTERNALSYM SDL_OPENGLBLIT}
  1042. SDL_RESIZABLE = $00000010; // This video mode may be resized
  1043. {$EXTERNALSYM SDL_RESIZABLE}
  1044. SDL_NOFRAME = $00000020; // No window caption or edge frame
  1045. {$EXTERNALSYM SDL_NOFRAME}
  1046. // Used internally (read-only)
  1047. SDL_HWACCEL = $00000100; // Blit uses hardware acceleration
  1048. {$EXTERNALSYM SDL_HWACCEL}
  1049. SDL_SRCCOLORKEY = $00001000; // Blit uses a source color key
  1050. {$EXTERNALSYM SDL_SRCCOLORKEY}
  1051. SDL_RLEACCELOK = $00002000; // Private flag
  1052. {$EXTERNALSYM SDL_RLEACCELOK}
  1053. SDL_RLEACCEL = $00004000; // Colorkey blit is RLE accelerated
  1054. {$EXTERNALSYM SDL_RLEACCEL}
  1055. SDL_SRCALPHA = $00010000; // Blit uses source alpha blending
  1056. {$EXTERNALSYM SDL_SRCALPHA}
  1057. SDL_SRCCLIPPING = $00100000; // Blit uses source clipping
  1058. {$EXTERNALSYM SDL_SRCCLIPPING}
  1059. SDL_PREALLOC = $01000000; // Surface uses preallocated memory
  1060. {$EXTERNALSYM SDL_PREALLOC}
  1061. { The most common video overlay formats.
  1062. For an explanation of these pixel formats, see:
  1063. http://www.webartz.com/fourcc/indexyuv.htm
  1064. For information on the relationship between color spaces, see:
  1065. http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html }
  1066. SDL_YV12_OVERLAY = $32315659; // Planar mode: Y + V + U (3 planes)
  1067. {$EXTERNALSYM SDL_YV12_OVERLAY}
  1068. SDL_IYUV_OVERLAY = $56555949; // Planar mode: Y + U + V (3 planes)
  1069. {$EXTERNALSYM SDL_IYUV_OVERLAY}
  1070. SDL_YUY2_OVERLAY = $32595559; // Packed mode: Y0+U0+Y1+V0 (1 plane)
  1071. {$EXTERNALSYM SDL_YUY2_OVERLAY}
  1072. SDL_UYVY_OVERLAY = $59565955; // Packed mode: U0+Y0+V0+Y1 (1 plane)
  1073. {$EXTERNALSYM SDL_UYVY_OVERLAY}
  1074. SDL_YVYU_OVERLAY = $55595659; // Packed mode: Y0+V0+Y1+U0 (1 plane)
  1075. {$EXTERNALSYM SDL_YVYU_OVERLAY}
  1076. // flags for SDL_SetPalette()
  1077. SDL_LOGPAL = $01;
  1078. {$EXTERNALSYM SDL_LOGPAL}
  1079. SDL_PHYSPAL = $02;
  1080. {$EXTERNALSYM SDL_PHYSPAL}
  1081. //SDL_mouse.h constants
  1082. { Used as a mask when testing buttons in buttonstate
  1083. Button 1: Left mouse button
  1084. Button 2: Middle mouse button
  1085. Button 3: Right mouse button
  1086. Button 4: Mouse Wheel Up
  1087. Button 5: Mouse Wheel Down
  1088. }
  1089. SDL_BUTTON_LEFT = 1;
  1090. {$EXTERNALSYM SDL_BUTTON_LEFT}
  1091. SDL_BUTTON_MIDDLE = 2;
  1092. {$EXTERNALSYM SDL_BUTTON_MIDDLE}
  1093. SDL_BUTTON_RIGHT = 3;
  1094. {$EXTERNALSYM SDL_BUTTON_RIGHT}
  1095. SDL_BUTTON_WHEELUP = 4;
  1096. {$EXTERNALSYM SDL_BUTTON_WHEELUP}
  1097. SDL_BUTTON_WHEELDOWN = 5;
  1098. {$EXTERNALSYM SDL_BUTTON_WHEELDOWN}
  1099. SDL_BUTTON_LMASK = SDL_PRESSED shl (SDL_BUTTON_LEFT - 1);
  1100. {$EXTERNALSYM SDL_BUTTON_LMASK}
  1101. SDL_BUTTON_MMASK = SDL_PRESSED shl (SDL_BUTTON_MIDDLE - 1);
  1102. {$EXTERNALSYM SDL_BUTTON_MMASK}
  1103. SDL_BUTTON_RMask = SDL_PRESSED shl (SDL_BUTTON_RIGHT - 1);
  1104. {$EXTERNALSYM SDL_BUTTON_RMask}
  1105. // SDL_active.h constants
  1106. // The available application states
  1107. SDL_APPMOUSEFOCUS = $01; // The app has mouse coverage
  1108. {$EXTERNALSYM SDL_APPMOUSEFOCUS}
  1109. SDL_APPINPUTFOCUS = $02; // The app has input focus
  1110. {$EXTERNALSYM SDL_APPINPUTFOCUS}
  1111. SDL_APPACTIVE = $04; // The application is active
  1112. {$EXTERNALSYM SDL_APPACTIVE}
  1113. // SDL_mutex.h constants
  1114. // Synchronization functions which can time out return this value
  1115. // they time out.
  1116. SDL_MUTEX_TIMEDOUT = 1;
  1117. {$EXTERNALSYM SDL_MUTEX_TIMEDOUT}
  1118. // This is the timeout value which corresponds to never time out
  1119. SDL_MUTEX_MAXWAIT = not Cardinal(0);
  1120. {$EXTERNALSYM SDL_MUTEX_MAXWAIT}
  1121. {TSDL_GrabMode = (
  1122. SDL_GRAB_QUERY,
  1123. SDL_GRAB_OFF,
  1124. SDL_GRAB_ON,
  1125. SDL_GRAB_FULLSCREEN ); // Used internally}
  1126. SDL_GRAB_QUERY = -1;
  1127. SDL_GRAB_OFF = 0;
  1128. SDL_GRAB_ON = 1;
  1129. //SDL_GRAB_FULLSCREEN // Used internally
  1130. type
  1131. THandle = Cardinal;
  1132. //SDL_types.h types
  1133. // Basic data types
  1134. SDL_Bool = (SDL_FALSE, SDL_TRUE);
  1135. TSDL_Bool = SDL_Bool;
  1136. PUInt8Array = ^TUInt8Array;
  1137. PUInt8 = ^UInt8;
  1138. UInt8 = Byte;
  1139. {$EXTERNALSYM UInt8}
  1140. TUInt8Array = array [0..MAXINT shr 1] of UInt8;
  1141. PUInt16 = ^UInt16;
  1142. UInt16 = word;
  1143. {$EXTERNALSYM UInt16}
  1144. PSInt16 = ^SInt16;
  1145. SInt16 = smallint;
  1146. {$EXTERNALSYM SInt16}
  1147. PUInt32 = ^UInt32;
  1148. UInt32 = Cardinal;
  1149. {$EXTERNALSYM UInt32}
  1150. SInt32 = Integer;
  1151. {$EXTERNALSYM SInt32}
  1152. PInt = ^Integer;
  1153. PShortInt = ^ShortInt;
  1154. PUInt64 = ^UInt64;
  1155. UInt64 = record
  1156. hi: UInt32;
  1157. lo: UInt32;
  1158. end;
  1159. {$EXTERNALSYM UInt64}
  1160. PSInt64 = ^SInt64;
  1161. SInt64 = record
  1162. hi: UInt32;
  1163. lo: UInt32;
  1164. end;
  1165. {$EXTERNALSYM SInt64}
  1166. TSDL_GrabMode = Integer;
  1167. // SDL_error.h types
  1168. TSDL_errorcode = (
  1169. SDL_ENOMEM,
  1170. SDL_EFREAD,
  1171. SDL_EFWRITE,
  1172. SDL_EFSEEK,
  1173. SDL_LASTERROR);
  1174. SDL_errorcode = TSDL_errorcode;
  1175. {$EXTERNALSYM SDL_errorcode}
  1176. TArg = record
  1177. case Byte of
  1178. 0: (value_ptr: Pointer);
  1179. (* #if 0 means: never
  1180. 1 : ( value_c : Byte );
  1181. *)
  1182. 2: (value_i: Integer);
  1183. 3: (value_f: double);
  1184. 4: (buf: array[0..ERR_MAX_STRLEN - 1] of Byte);
  1185. end;
  1186. PSDL_error = ^TSDL_error;
  1187. TSDL_error = record
  1188. { This is a numeric value corresponding to the current error }
  1189. error: Integer;
  1190. { This is a key used to index into a language hashtable containing
  1191. internationalized versions of the SDL error messages. If the key
  1192. is not in the hashtable, or no hashtable is available, the key is
  1193. used directly as an error message format string. }
  1194. key: array[0..ERR_MAX_STRLEN - 1] of Byte;
  1195. { These are the arguments for the error functions }
  1196. argc: Integer;
  1197. args: array[0..ERR_MAX_ARGS - 1] of TArg;
  1198. end;
  1199. // SDL_rwops.h types
  1200. // This is the read/write operation structure -- very basic
  1201. // some helper types to handle the unions
  1202. // "packed" is only guessed
  1203. TStdio = record
  1204. autoclose: Integer;
  1205. // FILE * is only defined in Kylix so we use a simple Pointer
  1206. fp: Pointer;
  1207. end;
  1208. TMem = record
  1209. base: PUInt8;
  1210. here: PUInt8;
  1211. stop: PUInt8;
  1212. end;
  1213. TUnknown = record
  1214. data1: Pointer;
  1215. end;
  1216. // first declare the pointer type
  1217. PSDL_RWops = ^TSDL_RWops;
  1218. // now the pointer to function types
  1219. {$IFNDEF __GPC__}
  1220. TSeek = function( context: PSDL_RWops; offset: Integer; whence: Integer ): Integer; cdecl;
  1221. TRead = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; maxnum : Integer ): Integer; cdecl;
  1222. TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; num: Integer ): Integer; cdecl;
  1223. TClose = function( context: PSDL_RWops ): Integer; cdecl;
  1224. {$ELSE}
  1225. TSeek = function( context: PSDL_RWops; offset: Integer; whence: Integer ): Integer;
  1226. TRead = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; maxnum : Integer ): Integer;
  1227. TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; num: Integer ): Integer;
  1228. TClose = function( context: PSDL_RWops ): Integer;
  1229. {$ENDIF}
  1230. // the variant record itself
  1231. TSDL_RWops = record
  1232. seek: TSeek;
  1233. read: TRead;
  1234. write: TWrite;
  1235. close: TClose;
  1236. // a keyword as name is not allowed
  1237. type_: UInt32;
  1238. // be warned! structure alignment may arise at this point
  1239. case Integer of
  1240. 0: (stdio: TStdio);
  1241. 1: (mem: TMem);
  1242. 2: (unknown: TUnknown);
  1243. end;
  1244. SDL_RWops = TSDL_RWops;
  1245. {$EXTERNALSYM SDL_RWops}
  1246. // SDL_timer.h types
  1247. // Function prototype for the timer callback function
  1248. {$IFNDEF __GPC__}
  1249. TSDL_TimerCallback = function( interval: UInt32 ): UInt32; cdecl;
  1250. {$ELSE}
  1251. TSDL_TimerCallback = function( interval: UInt32 ): UInt32;
  1252. {$ENDIF}
  1253. { New timer API, supports multiple timers
  1254. Written by Stephane Peter <[email protected]> }
  1255. { Function prototype for the new timer callback function.
  1256. The callback function is passed the current timer interval and returns
  1257. the next timer interval. If the returned value is the same as the one
  1258. passed in, the periodic alarm continues, otherwise a new alarm is
  1259. scheduled. If the callback returns 0, the periodic alarm is cancelled. }
  1260. {$IFNDEF __GPC__}
  1261. TSDL_NewTimerCallback = function( interval: UInt32; param: Pointer ): UInt32; cdecl;
  1262. {$ELSE}
  1263. TSDL_NewTimerCallback = function( interval: UInt32; param: Pointer ): UInt32;
  1264. {$ENDIF}
  1265. // Definition of the timer ID type
  1266. PSDL_TimerID = ^TSDL_TimerID;
  1267. TSDL_TimerID = record
  1268. interval: UInt32;
  1269. callback: TSDL_NewTimerCallback;
  1270. param: Pointer;
  1271. last_alarm: UInt32;
  1272. next: PSDL_TimerID;
  1273. end;
  1274. {$IFNDEF __GPC__}
  1275. TSDL_AudioSpecCallback = procedure( userdata: Pointer; stream: PUInt8; len: Integer ); cdecl;
  1276. {$ELSE}
  1277. TSDL_AudioSpecCallback = procedure( userdata: Pointer; stream: PUInt8; len: Integer );
  1278. {$ENDIF}
  1279. // SDL_audio.h types
  1280. // The calculated values in this structure are calculated by SDL_OpenAudio()
  1281. PSDL_AudioSpec = ^TSDL_AudioSpec;
  1282. TSDL_AudioSpec = record
  1283. freq: Integer; // DSP frequency -- samples per second
  1284. format: UInt16; // Audio data format
  1285. channels: UInt8; // Number of channels: 1 mono, 2 stereo
  1286. silence: UInt8; // Audio buffer silence value (calculated)
  1287. samples: UInt16; // Audio buffer size in samples
  1288. padding: UInt16; // Necessary for some compile environments
  1289. size: UInt32; // Audio buffer size in bytes (calculated)
  1290. { This function is called when the audio device needs more data.
  1291. 'stream' is a pointer to the audio data buffer
  1292. 'len' is the length of that buffer in bytes.
  1293. Once the callback returns, the buffer will no longer be valid.
  1294. Stereo samples are stored in a LRLRLR ordering.}
  1295. callback: TSDL_AudioSpecCallback;
  1296. userdata: Pointer;
  1297. end;
  1298. // A structure to hold a set of audio conversion filters and buffers
  1299. PSDL_AudioCVT = ^TSDL_AudioCVT;
  1300. PSDL_AudioCVTFilter = ^TSDL_AudioCVTFilter;
  1301. TSDL_AudioCVTFilter = record
  1302. cvt: PSDL_AudioCVT;
  1303. format: UInt16;
  1304. end;
  1305. PSDL_AudioCVTFilterArray = ^TSDL_AudioCVTFilterArray;
  1306. TSDL_AudioCVTFilterArray = array[0..9] of PSDL_AudioCVTFilter;
  1307. TSDL_AudioCVT = record
  1308. needed: Integer; // Set to 1 if conversion possible
  1309. src_format: UInt16; // Source audio format
  1310. dst_format: UInt16; // Target audio format
  1311. rate_incr: double; // Rate conversion increment
  1312. buf: PUInt8; // Buffer to hold entire audio data
  1313. len: Integer; // Length of original audio buffer
  1314. len_cvt: Integer; // Length of converted audio buffer
  1315. len_mult: Integer; // buffer must be len*len_mult big
  1316. len_ratio: double; // Given len, final size is len*len_ratio
  1317. filters: TSDL_AudioCVTFilterArray;
  1318. filter_index: Integer; // Current audio conversion function
  1319. end;
  1320. TSDL_Audiostatus = (
  1321. SDL_AUDIO_STOPPED,
  1322. SDL_AUDIO_PLAYING,
  1323. SDL_AUDIO_PAUSED
  1324. );
  1325. // SDL_cdrom.h types
  1326. TSDL_CDStatus = (
  1327. CD_ERROR,
  1328. CD_TRAYEMPTY,
  1329. CD_STOPPED,
  1330. CD_PLAYING,
  1331. CD_PAUSED );
  1332. PSDL_CDTrack = ^TSDL_CDTrack;
  1333. TSDL_CDTrack = record
  1334. id: UInt8; // Track number
  1335. type_: UInt8; // Data or audio track
  1336. unused: UInt16;
  1337. length: UInt32; // Length, in frames, of this track
  1338. offset: UInt32; // Offset, in frames, from start of disk
  1339. end;
  1340. // This structure is only current as of the last call to SDL_CDStatus()
  1341. PSDL_CD = ^TSDL_CD;
  1342. TSDL_CD = record
  1343. id: Integer; // Private drive identifier
  1344. status: TSDL_CDStatus; // Current drive status
  1345. // The rest of this structure is only valid if there's a CD in drive
  1346. numtracks: Integer; // Number of tracks on disk
  1347. cur_track: Integer; // Current track position
  1348. cur_frame: Integer; // Current frame offset within current track
  1349. track: array[0..SDL_MAX_TRACKS] of TSDL_CDTrack;
  1350. end;
  1351. //SDL_joystick.h types
  1352. PTransAxis = ^TTransAxis;
  1353. TTransAxis = record
  1354. offset: Integer;
  1355. scale: single;
  1356. end;
  1357. // The private structure used to keep track of a joystick
  1358. PJoystick_hwdata = ^TJoystick_hwdata;
  1359. TJoystick_hwdata = record
  1360. // joystick ID
  1361. id: Integer;
  1362. // values used to translate device-specific coordinates into SDL-standard ranges
  1363. transaxis: array[0..5] of TTransAxis;
  1364. end;
  1365. PBallDelta = ^TBallDelta;
  1366. TBallDelta = record
  1367. dx: Integer;
  1368. dy: Integer;
  1369. end; // Current ball motion deltas
  1370. // The SDL joystick structure
  1371. PSDL_Joystick = ^TSDL_Joystick;
  1372. TSDL_Joystick = record
  1373. index: UInt8; // Device index
  1374. name: PChar; // Joystick name - system dependent
  1375. naxes: Integer; // Number of axis controls on the joystick
  1376. axes: PUInt16; // Current axis states
  1377. nhats: Integer; // Number of hats on the joystick
  1378. hats: PUInt8; // Current hat states
  1379. nballs: Integer; // Number of trackballs on the joystick
  1380. balls: PBallDelta; // Current ball motion deltas
  1381. nbuttons: Integer; // Number of buttons on the joystick
  1382. buttons: PUInt8; // Current button states
  1383. hwdata: PJoystick_hwdata; // Driver dependent information
  1384. ref_count: Integer; // Reference count for multiple opens
  1385. end;
  1386. // SDL_verion.h types
  1387. PSDL_version = ^TSDL_version;
  1388. TSDL_version = record
  1389. major: UInt8;
  1390. minor: UInt8;
  1391. patch: UInt8;
  1392. end;
  1393. // SDL_keyboard.h types
  1394. TSDLKey = LongWord;
  1395. TSDLMod = LongWord;
  1396. PSDL_KeySym = ^TSDL_KeySym;
  1397. TSDL_KeySym = record
  1398. scancode: UInt8; // hardware specific scancode
  1399. sym: TSDLKey; // SDL virtual keysym
  1400. modifier: TSDLMod; // current key modifiers
  1401. unicode: UInt16; // translated character
  1402. end;
  1403. // SDL_events.h types
  1404. {Checks the event queue for messages and optionally returns them.
  1405. If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
  1406. the back of the event queue.
  1407. If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
  1408. of the event queue, matching 'mask', will be returned and will not
  1409. be removed from the queue.
  1410. If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
  1411. of the event queue, matching 'mask', will be returned and will be
  1412. removed from the queue.
  1413. This function returns the number of events actually stored, or -1
  1414. if there was an error. This function is thread-safe. }
  1415. TSDL_EventAction = (SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT);
  1416. // Application visibility event structure
  1417. TSDL_ActiveEvent = record
  1418. type_: UInt8; // SDL_ACTIVEEVENT
  1419. gain: UInt8; // Whether given states were gained or lost (1/0)
  1420. state: UInt8; // A mask of the focus states
  1421. end;
  1422. // Keyboard event structure
  1423. TSDL_KeyboardEvent = record
  1424. type_: UInt8; // SDL_KEYDOWN or SDL_KEYUP
  1425. which: UInt8; // The keyboard device index
  1426. state: UInt8; // SDL_PRESSED or SDL_RELEASED
  1427. keysym: TSDL_KeySym;
  1428. end;
  1429. // Mouse motion event structure
  1430. TSDL_MouseMotionEvent = record
  1431. type_: UInt8; // SDL_MOUSEMOTION
  1432. which: UInt8; // The mouse device index
  1433. state: UInt8; // The current button state
  1434. x, y: UInt16; // The X/Y coordinates of the mouse
  1435. xrel: SInt16; // The relative motion in the X direction
  1436. yrel: SInt16; // The relative motion in the Y direction
  1437. end;
  1438. // Mouse button event structure
  1439. TSDL_MouseButtonEvent = record
  1440. type_: UInt8; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
  1441. which: UInt8; // The mouse device index
  1442. button: UInt8; // The mouse button index
  1443. state: UInt8; // SDL_PRESSED or SDL_RELEASED
  1444. x: UInt16; // The X coordinates of the mouse at press time
  1445. y: UInt16; // The Y coordinates of the mouse at press time
  1446. end;
  1447. // Joystick axis motion event structure
  1448. TSDL_JoyAxisEvent = record
  1449. type_: UInt8; // SDL_JOYAXISMOTION
  1450. which: UInt8; // The joystick device index
  1451. axis: UInt8; // The joystick axis index
  1452. value: SInt16; // The axis value (range: -32768 to 32767)
  1453. end;
  1454. // Joystick trackball motion event structure
  1455. TSDL_JoyBallEvent = record
  1456. type_: UInt8; // SDL_JOYAVBALLMOTION
  1457. which: UInt8; // The joystick device index
  1458. ball: UInt8; // The joystick trackball index
  1459. xrel: SInt16; // The relative motion in the X direction
  1460. yrel: SInt16; // The relative motion in the Y direction
  1461. end;
  1462. // Joystick hat position change event structure
  1463. TSDL_JoyHatEvent = record
  1464. type_: UInt8; // SDL_JOYHATMOTION */
  1465. which: UInt8; // The joystick device index */
  1466. hat: UInt8; // The joystick hat index */
  1467. value: UInt8; { The hat position value:
  1468. 8 1 2
  1469. 7 0 3
  1470. 6 5 4
  1471. Note that zero means the POV is centered. }
  1472. end;
  1473. // Joystick button event structure
  1474. TSDL_JoyButtonEvent = record
  1475. type_: UInt8; // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
  1476. which: UInt8; // The joystick device index
  1477. button: UInt8; // The joystick button index
  1478. state: UInt8; // SDL_PRESSED or SDL_RELEASED
  1479. end;
  1480. { The "window resized" event
  1481. When you get this event, you are responsible for setting a new video
  1482. mode with the new width and height. }
  1483. TSDL_ResizeEvent = record
  1484. type_: UInt8; // SDL_VIDEORESIZE
  1485. w: Integer; // New width
  1486. h: Integer; // New height
  1487. end;
  1488. // The "quit requested" event
  1489. PSDL_QuitEvent = ^TSDL_QuitEvent;
  1490. TSDL_QuitEvent = record
  1491. type_: UInt8;
  1492. end;
  1493. // A user-defined event type
  1494. PSDL_UserEvent = ^TSDL_UserEvent;
  1495. TSDL_UserEvent = record
  1496. type_: UInt8; // SDL_USEREVENT through SDL_NUMEVENTS-1
  1497. code: Integer; // User defined event code */
  1498. data1: Pointer; // User defined data pointer */
  1499. data2: Pointer; // User defined data pointer */
  1500. end;
  1501. // The "screen redraw" event
  1502. PSDL_ExposeEvent = ^TSDL_ExposeEvent;
  1503. TSDL_ExposeEvent = record
  1504. type_ : Uint8; // SDL_VIDEOEXPOSE
  1505. end;
  1506. {$IFDEF Unix}
  1507. //These are the various supported subsystems under UNIX
  1508. TSDL_SysWm = ( SDL_SYSWM_X11 ) ;
  1509. {$ENDIF}
  1510. // The windows custom event structure
  1511. {$IFDEF Win32}
  1512. PSDL_SysWMmsg = ^TSDL_SysWMmsg;
  1513. TSDL_SysWMmsg = record
  1514. version: TSDL_version;
  1515. h_wnd: HWND; // The window for the message
  1516. msg: UInt; // The type of message
  1517. w_Param: WPARAM; // WORD message parameter
  1518. lParam: LPARAM; // LONG message parameter
  1519. end;
  1520. {$ELSE}
  1521. {$IFDEF Unix}
  1522. { The Linux custom event structure }
  1523. PSDL_SysWMmsg = ^TSDL_SysWMmsg;
  1524. TSDL_SysWMmsg = record
  1525. version : TSDL_version;
  1526. subsystem : TSDL_SysWm;
  1527. {$IFDEF FPC}
  1528. event : TXEvent;
  1529. {$ELSE}
  1530. event : XEvent;
  1531. {$ENDIF}
  1532. end;
  1533. {$ELSE}
  1534. { The generic custom event structure }
  1535. PSDL_SysWMmsg = ^TSDL_SysWMmsg;
  1536. TSDL_SysWMmsg = record
  1537. version: TSDL_version;
  1538. data: Integer;
  1539. end;
  1540. {$ENDIF}
  1541. {$ENDIF}
  1542. // The Windows custom window manager information structure
  1543. {$IFDEF Win32}
  1544. PSDL_SysWMinfo = ^TSDL_SysWMinfo;
  1545. TSDL_SysWMinfo = record
  1546. version : TSDL_version;
  1547. window : HWnd; // The display window
  1548. end;
  1549. {$ELSE}
  1550. // The Linux custom window manager information structure
  1551. {$IFDEF Unix}
  1552. TX11 = record
  1553. display : PDisplay; // The X11 display
  1554. window : TWindow ; // The X11 display window */
  1555. {* These locking functions should be called around
  1556. any X11 functions using the display variable.
  1557. They lock the event thread, so should not be
  1558. called around event functions or from event filters.
  1559. *}
  1560. lock_func : Pointer;
  1561. unlock_func : Pointer;
  1562. // Introduced in SDL 1.0.2
  1563. fswindow : TWindow ; // The X11 fullscreen window */
  1564. wmwindow : TWindow ; // The X11 managed input window */
  1565. end;
  1566. PSDL_SysWMinfo = ^TSDL_SysWMinfo;
  1567. TSDL_SysWMinfo = record
  1568. version : TSDL_version ;
  1569. subsystem : TSDL_SysWm;
  1570. X11 : TX11;
  1571. end;
  1572. {$ELSE}
  1573. // The generic custom window manager information structure
  1574. PSDL_SysWMinfo = ^TSDL_SysWMinfo;
  1575. TSDL_SysWMinfo = record
  1576. version : TSDL_version ;
  1577. data : integer;
  1578. end;
  1579. {$ENDIF}
  1580. {$ENDIF}
  1581. PSDL_SysWMEvent = ^TSDL_SysWMEvent;
  1582. TSDL_SysWMEvent = record
  1583. type_: UInt8;
  1584. msg: PSDL_SysWMmsg;
  1585. end;
  1586. PSDL_Event = ^TSDL_Event;
  1587. TSDL_Event = record
  1588. case UInt8 of
  1589. SDL_NOEVENT: (type_: byte);
  1590. SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
  1591. SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
  1592. SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
  1593. SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent );
  1594. SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent );
  1595. SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent );
  1596. SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent );
  1597. SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent );
  1598. SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent );
  1599. SDL_QUITEV: (quit: TSDL_QuitEvent );
  1600. SDL_USEREVENT : ( user : TSDL_UserEvent );
  1601. SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent );
  1602. end;
  1603. { This function sets up a filter to process all events before they
  1604. change internal state and are posted to the internal event queue.
  1605. The filter is protypted as: }
  1606. {$IFNDEF __GPC__}
  1607. TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
  1608. {$ELSE}
  1609. TSDL_EventFilter = function( event : PSDL_Event ): Integer;
  1610. {$ENDIF}
  1611. // SDL_video.h types
  1612. // Useful data types
  1613. PPSDL_Rect = ^PSDL_Rect;
  1614. PSDL_Rect = ^TSDL_Rect;
  1615. TSDL_Rect = record
  1616. x, y: SInt16;
  1617. w, h: UInt16;
  1618. end;
  1619. SDL_Rect = TSDL_Rect;
  1620. {$EXTERNALSYM SDL_Rect}
  1621. PSDL_Color = ^TSDL_Color;
  1622. TSDL_Color = record
  1623. r: UInt8;
  1624. g: UInt8;
  1625. b: UInt8;
  1626. unused: UInt8;
  1627. end;
  1628. PSDL_ColorArray = ^TSDL_ColorArray;
  1629. TSDL_ColorArray = array[0..65000] of TSDL_Color;
  1630. PSDL_Palette = ^TSDL_Palette;
  1631. TSDL_Palette = record
  1632. ncolors: Integer;
  1633. colors: PSDL_ColorArray;
  1634. end;
  1635. // Everything in the pixel format structure is read-only
  1636. PSDL_PixelFormat = ^TSDL_PixelFormat;
  1637. TSDL_PixelFormat = record
  1638. palette: PSDL_Palette;
  1639. BitsPerPixel: UInt8;
  1640. BytesPerPixel: UInt8;
  1641. Rloss: UInt8;
  1642. Gloss: UInt8;
  1643. Bloss: UInt8;
  1644. Aloss: UInt8;
  1645. Rshift: UInt8;
  1646. Gshift: UInt8;
  1647. Bshift: UInt8;
  1648. Ashift: UInt8;
  1649. RMask: UInt32;
  1650. GMask: UInt32;
  1651. BMask: UInt32;
  1652. AMask: UInt32;
  1653. colorkey: UInt32; // RGB color key information
  1654. alpha: UInt8; // Alpha value information (per-surface alpha)
  1655. end;
  1656. {$IFDEF WIN32}
  1657. {PPrivate_hwdata = ^TPrivate_hwdata;
  1658. TPrivate_hwdata = record
  1659. dd_surface : IDIRECTDRAWSURFACE3;
  1660. dd_writebuf : IDIRECTDRAWSURFACE3;
  1661. end;}
  1662. {ELSE}
  1663. {$ENDIF}
  1664. // The structure passed to the low level blit functions
  1665. PSDL_BlitInfo = ^TSDL_BlitInfo;
  1666. TSDL_BlitInfo = record
  1667. s_pixels: PUInt8;
  1668. s_width: Integer;
  1669. s_height: Integer;
  1670. s_skip: Integer;
  1671. d_pixels: PUInt8;
  1672. d_width: Integer;
  1673. d_height: Integer;
  1674. d_skip: Integer;
  1675. aux_data: Pointer;
  1676. src: PSDL_PixelFormat;
  1677. table: PUInt8;
  1678. dst: PSDL_PixelFormat;
  1679. end;
  1680. // typedef for private surface blitting functions
  1681. PSDL_Surface = ^TSDL_Surface;
  1682. {$IFNDEF __GPC__}
  1683. TSDL_Blit = function( src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect ): Integer; cdecl;
  1684. {$ELSE}
  1685. TSDL_Blit = function( src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect ): Integer;
  1686. {$ENDIF}
  1687. // The type definition for the low level blit functions
  1688. //TSDL_LoBlit = procedure( info : PSDL_BlitInfo ); cdecl;
  1689. // This is the private info structure for software accelerated blits
  1690. {PPrivate_swaccel = ^TPrivate_swaccel;
  1691. TPrivate_swaccel = record
  1692. blit : TSDL_LoBlit;
  1693. aux_data : Pointer;
  1694. end;}
  1695. // Blit mapping definition
  1696. {PSDL_BlitMap = ^TSDL_BlitMap;
  1697. TSDL_BlitMap = record
  1698. dst : PSDL_Surface;
  1699. identity : Integer;
  1700. table : PUInt8;
  1701. hw_blit : TSDL_Blit;
  1702. sw_blit : TSDL_Blit;
  1703. hw_data : PPrivate_hwaccel;
  1704. sw_data : PPrivate_swaccel;
  1705. // the version count matches the destination; mismatch indicates an invalid mapping
  1706. format_version : Cardinal;
  1707. end;}
  1708. TSDL_Surface = record
  1709. flags: UInt32; // Read-only
  1710. format: PSDL_PixelFormat; // Read-only
  1711. w, h: Integer; // Read-only
  1712. pitch: UInt16; // Read-only
  1713. pixels: Pointer; // Read-write
  1714. offset: Integer; // Private
  1715. hwdata: Pointer; //TPrivate_hwdata; Hardware-specific surface info
  1716. // clipping information:
  1717. clip_rect: TSDL_Rect; // Read-only
  1718. unused1: UInt32; // for binary compatibility
  1719. // Allow recursive locks
  1720. locked: UInt32; // Private
  1721. // info for fast blit mapping to other surfaces
  1722. Blitmap: Pointer; // PSDL_BlitMap; // Private
  1723. // format version, bumped at every change to invalidate blit maps
  1724. format_version: Cardinal; // Private
  1725. refcount: Integer;
  1726. end;
  1727. // Useful for determining the video hardware capabilities
  1728. PSDL_VideoInfo = ^TSDL_VideoInfo;
  1729. TSDL_VideoInfo = record
  1730. hw_available: UInt8; // Hardware and WindowManager flags in first 2 bits ( see below )
  1731. {hw_available: 1; // Can you create hardware surfaces
  1732. wm_available: 1; // Can you talk to a window manager?
  1733. UnusedBits1: 6;}
  1734. blit_hw: UInt8; // Blit Hardware flags. See below for which bits do what
  1735. {UnusedBits2: 1;
  1736. blit_hw: 1; // Flag:UInt32 Accelerated blits HW --> HW
  1737. blit_hw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey
  1738. blit_hw_A: 1; // Flag:UInt32 Accelerated blits with Alpha
  1739. blit_sw: 1; // Flag:UInt32 Accelerated blits SW --> HW
  1740. blit_sw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey
  1741. blit_sw_A: 1; // Flag:UInt32 Accelerated blits with Alpha
  1742. blit_fill: 1; // Flag:UInt32 Accelerated color fill}
  1743. UnusedBits3: UInt8; // Unused at this point
  1744. video_mem: UInt32; // The total amount of video memory (in K)
  1745. vfmt: PSDL_PixelFormat; // Value: The format of the video surface
  1746. end;
  1747. // The YUV hardware video overlay
  1748. PSDL_Overlay = ^TSDL_Overlay;
  1749. TSDL_Overlay = record
  1750. format: UInt32; // Overlay format
  1751. w, h: Integer; // Width and height of overlay
  1752. planes: Integer; // Number of planes in the overlay. Usually either 1 or 3
  1753. pitches: PUInt16;
  1754. // An array of pitches, one for each plane. Pitch is the length of a row in bytes.
  1755. pixels: PUInt8;
  1756. // An array of pointers to teh data of each plane. The overlay should be locked before these pointers are used.
  1757. hw_overlay: UInt32;
  1758. // This will be set to 1 if the overlay is hardware accelerated.
  1759. end;
  1760. // Public enumeration for setting the OpenGL window attributes.
  1761. TSDL_GLAttr = (
  1762. SDL_GL_RED_SIZE,
  1763. SDL_GL_GREEN_SIZE,
  1764. SDL_GL_BLUE_SIZE,
  1765. SDL_GL_ALPHA_SIZE,
  1766. SDL_GL_BUFFER_SIZE,
  1767. SDL_GL_DOUBLEBUFFER,
  1768. SDL_GL_DEPTH_SIZE,
  1769. SDL_GL_STENCIL_SIZE,
  1770. SDL_GL_ACCUM_RED_SIZE,
  1771. SDL_GL_ACCUM_GREEN_SIZE,
  1772. SDL_GL_ACCUM_BLUE_SIZE,
  1773. SDL_GL_ACCUM_ALPHA_SIZE,
  1774. SDL_GL_STEREO,
  1775. SDL_GL_MULTISAMPLEBUFFERS,
  1776. SDL_GL_MULTISAMPLESAMPLES);
  1777. PSDL_Cursor = ^TSDL_Cursor;
  1778. TSDL_Cursor = record
  1779. area: TSDL_Rect; // The area of the mouse cursor
  1780. hot_x, hot_y: SInt16; // The "tip" of the cursor
  1781. data: PUInt8; // B/W cursor data
  1782. mask: PUInt8; // B/W cursor mask
  1783. save: array[1..2] of PUInt8; // Place to save cursor area
  1784. wm_cursor: Pointer; // Window-manager cursor
  1785. end;
  1786. // SDL_mutex.h types
  1787. {$IFDEF WIN32}
  1788. PSDL_Mutex = ^TSDL_Mutex;
  1789. TSDL_Mutex = record
  1790. id: THANDLE;
  1791. end;
  1792. {$ENDIF}
  1793. {$IFDEF Unix}
  1794. PSDL_Mutex = ^TSDL_Mutex;
  1795. TSDL_mutex = record
  1796. id: pthread_mutex_t;
  1797. {$IFDEF PTHREAD_NO_RECURSIVE_MUTEX}
  1798. recursive: Integer;
  1799. owner: pthread_t;
  1800. {$ENDIF}
  1801. end;
  1802. {$ENDIF}
  1803. {$IFDEF __MACH__}
  1804. {$define USE_NAMED_SEMAPHORES}
  1805. // Broken sem_getvalue() in MacOS X Public Beta */
  1806. {$define BROKEN_SEMGETVALUE}
  1807. {$ENDIF}
  1808. PSDL_semaphore = ^TSDL_semaphore;
  1809. {$IFDEF WIN32}
  1810. // Win32 or Machintosh
  1811. TSDL_semaphore = record
  1812. id: THANDLE;
  1813. count: UInt32;
  1814. end;
  1815. {$ELSE}
  1816. {$IFDEF FPC}
  1817. // This should be semaphore.h
  1818. __sem_lock_t = {packed} record { Not in header file - anonymous }
  1819. status: Longint;
  1820. spinlock: Integer;
  1821. end;
  1822. sem_t = {packed} record
  1823. __sem_lock: __sem_lock_t;
  1824. __sem_value: Integer;
  1825. __sem_waiting: longint ; {_pthread_queue;}
  1826. end;
  1827. {$ENDIF}
  1828. TSDL_semaphore = record
  1829. sem: Pointer; //PSem_t;
  1830. {$IFNDEF USE_NAMED_SEMAPHORES}
  1831. sem_data: Sem_t;
  1832. {$ENDIF}
  1833. {$IFDEF BROKEN_SEMGETVALUE}
  1834. { This is a little hack for MacOS X -
  1835. It's not thread-safe, but it's better than nothing }
  1836. sem_value: Integer;
  1837. {$ENDIF}
  1838. end;
  1839. {$ENDIF}
  1840. PSDL_Sem = ^TSDL_Sem;
  1841. TSDL_Sem = TSDL_Semaphore;
  1842. PSDL_Cond = ^TSDL_Cond;
  1843. TSDL_Cond = record
  1844. {$IFDEF Unix}
  1845. cond: pthread_cond_t;
  1846. {$ELSE}
  1847. // Generic Cond structure
  1848. lock: PSDL_mutex;
  1849. waiting: Integer;
  1850. signals: Integer;
  1851. wait_sem: PSDL_Sem;
  1852. wait_done: PSDL_Sem;
  1853. {$ENDIF}
  1854. end;
  1855. // SDL_thread.h types
  1856. {$IFDEF WIN32}
  1857. TSYS_ThreadHandle = THandle;
  1858. {$ENDIF}
  1859. {$IFDEF Unix}
  1860. TSYS_ThreadHandle = pthread_t;
  1861. {$ENDIF}
  1862. { This is the system-independent thread info structure }
  1863. PSDL_Thread = ^TSDL_Thread;
  1864. TSDL_Thread = record
  1865. threadid: UInt32;
  1866. handle: TSYS_ThreadHandle;
  1867. status: Integer;
  1868. errbuf: TSDL_Error;
  1869. data: Pointer;
  1870. end;
  1871. // Helper Types
  1872. // Keyboard State Array ( See demos for how to use )
  1873. PKeyStateArr = ^TKeyStateArr;
  1874. TKeyStateArr = array[0..65000] of UInt8;
  1875. // Types required so we don't need to use Windows.pas
  1876. PInteger = ^Integer;
  1877. PByte = ^Byte;
  1878. PWord = ^Word;
  1879. PLongWord = ^Longword;
  1880. // General arrays
  1881. PByteArray = ^TByteArray;
  1882. TByteArray = array[0..32767] of Byte;
  1883. PWordArray = ^TWordArray;
  1884. TWordArray = array[0..16383] of Word;
  1885. PPoint = ^TPoint;
  1886. TPoint = record
  1887. x: Longint;
  1888. y: Longint;
  1889. end;
  1890. PRect = ^TRect;
  1891. TRect = record
  1892. case Integer of
  1893. 0: (Left, Top, Right, Bottom: Integer);
  1894. 1: (TopLeft, BottomRight: TPoint);
  1895. end;
  1896. { Generic procedure pointer }
  1897. TProcedure = procedure;
  1898. {------------------------------------------------------------------------------}
  1899. { initialization }
  1900. {------------------------------------------------------------------------------}
  1901. { This function loads the SDL dynamically linked library and initializes
  1902. the subsystems specified by 'flags' (and those satisfying dependencies)
  1903. Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
  1904. signal handlers for some commonly ignored fatal signals (like SIGSEGV) }
  1905. function SDL_Init( flags : UInt32 ) : Integer;
  1906. cdecl; external {$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1907. {$EXTERNALSYM SDL_Init}
  1908. // This function initializes specific SDL subsystems
  1909. function SDL_InitSubSystem( flags : UInt32 ) : Integer;
  1910. cdecl; external {$IFDEF __GPC__}name 'SDL_InitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1911. {$EXTERNALSYM SDL_InitSubSystem}
  1912. // This function cleans up specific SDL subsystems
  1913. procedure SDL_QuitSubSystem( flags : UInt32 );
  1914. cdecl; external {$IFDEF __GPC__}name 'SDL_QuitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1915. {$EXTERNALSYM SDL_QuitSubSystem}
  1916. { This function returns mask of the specified subsystems which have
  1917. been initialized.
  1918. If 'flags' is 0, it returns a mask of all initialized subsystems. }
  1919. function SDL_WasInit( flags : UInt32 ): UInt32;
  1920. cdecl; external {$IFDEF __GPC__}name 'SDL_WasInit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1921. {$EXTERNALSYM SDL_WasInit}
  1922. { This function cleans up all initialized subsystems and unloads the
  1923. dynamically linked library. You should call it upon all exit conditions. }
  1924. procedure SDL_Quit;
  1925. cdecl; external {$IFDEF __GPC__}name 'SDL_Quit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1926. {$EXTERNALSYM SDL_Quit}
  1927. {$IFDEF WIN32}
  1928. // This should be called from your WinMain() function, if any
  1929. function SDL_RegisterApp(name: PChar; style: UInt32; h_Inst: Pointer): Integer;
  1930. cdecl; external {$IFDEF __GPC__}name 'SDL_RegisterApp'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1931. {$EXTERNALSYM SDL_RegisterApp}
  1932. {$ENDIF}
  1933. {$IFDEF __MACH__}
  1934. // This should be called from your main() function, if any
  1935. procedure SDL_InitQuickDraw( the_qd: QDGlobals );
  1936. cdecl; external {$IFDEF __GPC__}name 'SDL_InitQuickDraw'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1937. {$EXTERNALSYM SDL_InitQuickDraw}
  1938. {$ENDIF}
  1939. {------------------------------------------------------------------------------}
  1940. { types }
  1941. {------------------------------------------------------------------------------}
  1942. // The number of elements in a table
  1943. function SDL_TableSize( table: PChar ): Integer;
  1944. {$EXTERNALSYM SDL_TABLESIZE}
  1945. {------------------------------------------------------------------------------}
  1946. { error-handling }
  1947. {------------------------------------------------------------------------------}
  1948. // Public functions
  1949. function SDL_GetError: PChar;
  1950. cdecl; external {$IFDEF __GPC__}name 'SDL_GetError'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1951. {$EXTERNALSYM SDL_GetError}
  1952. procedure SDL_SetError(fmt: PChar);
  1953. cdecl; external {$IFDEF __GPC__}name 'SDL_SetError'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1954. {$EXTERNALSYM SDL_SetError}
  1955. procedure SDL_ClearError;
  1956. cdecl; external {$IFDEF __GPC__}name 'SDL_ClearError'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1957. {$EXTERNALSYM SDL_ClearError}
  1958. {$IFNDEF WIN32}
  1959. procedure SDL_Error(Code: TSDL_errorcode);
  1960. cdecl; external {$IFDEF __GPC__}name 'SDL_Error'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1961. {$EXTERNALSYM SDL_Error}
  1962. {$ENDIF}
  1963. // Private error message function - used internally
  1964. procedure SDL_OutOfMemory;
  1965. {------------------------------------------------------------------------------}
  1966. { io handling }
  1967. {------------------------------------------------------------------------------}
  1968. // Functions to create SDL_RWops structures from various data sources
  1969. function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops;
  1970. cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromFile'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1971. {$EXTERNALSYM SDL_RWFromFile}
  1972. procedure SDL_FreeRW(area: PSDL_RWops);
  1973. cdecl; external {$IFDEF __GPC__}name 'SDL_FreeRW'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1974. {$EXTERNALSYM SDL_FreeRW}
  1975. //fp is FILE *fp ???
  1976. function SDL_RWFromFP(fp: Pointer; autoclose: Integer): PSDL_RWops;
  1977. cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromFP'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1978. {$EXTERNALSYM SDL_RWFromFP}
  1979. function SDL_RWFromMem(mem: Pointer; size: Integer): PSDL_RWops;
  1980. cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromMem'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1981. {$EXTERNALSYM SDL_RWFromMem}
  1982. function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
  1983. cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromConstMem'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1984. {$EXTERNALSYM SDL_RWFromConstMem}
  1985. function SDL_AllocRW: PSDL_RWops;
  1986. cdecl; external {$IFDEF __GPC__}name 'SDL_AllocRW'{$ELSE} SDLLibName{$ENDIF __GPC__};
  1987. {$EXTERNALSYM SDL_AllocRW}
  1988. function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer;
  1989. {$EXTERNALSYM SDL_RWSeek}
  1990. function SDL_RWTell(context: PSDL_RWops): Integer;
  1991. {$EXTERNALSYM SDL_RWTell}
  1992. function SDL_RWRead(context: PSDL_RWops; ptr: Pointer; size: Integer; n : Integer): Integer;
  1993. {$EXTERNALSYM SDL_RWRead}
  1994. function SDL_RWWrite(context: PSDL_RWops; ptr: Pointer; size: Integer; n : Integer): Integer;
  1995. {$EXTERNALSYM SDL_RWWrite}
  1996. function SDL_RWClose(context: PSDL_RWops): Integer;
  1997. {$EXTERNALSYM SDL_RWClose}
  1998. {------------------------------------------------------------------------------}
  1999. { time-handling }
  2000. {------------------------------------------------------------------------------}
  2001. { Get the number of milliseconds since the SDL library initialization. }
  2002. { Note that this value wraps if the program runs for more than ~49 days. }
  2003. function SDL_GetTicks: UInt32;
  2004. cdecl; external {$IFDEF __GPC__}name 'SDL_GetTicks'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2005. {$EXTERNALSYM SDL_GetTicks}
  2006. // Wait a specified number of milliseconds before returning
  2007. procedure SDL_Delay(msec: UInt32);
  2008. cdecl; external {$IFDEF __GPC__}name 'SDL_Delay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2009. {$EXTERNALSYM SDL_Delay}
  2010. { Add a new timer to the pool of timers already running. }
  2011. { Returns a timer ID, or NULL when an error occurs. }
  2012. function SDL_AddTimer(interval: UInt32; callback: TSDL_NewTimerCallback; param : Pointer): PSDL_TimerID;
  2013. cdecl; external {$IFDEF __GPC__}name 'SDL_AddTimer'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2014. {$EXTERNALSYM SDL_AddTimer}
  2015. { Remove one of the multiple timers knowing its ID. }
  2016. { Returns a boolean value indicating success. }
  2017. function SDL_RemoveTimer(t: PSDL_TimerID): TSDL_Bool;
  2018. cdecl; external {$IFDEF __GPC__}name 'SDL_RemoveTimer'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2019. {$EXTERNALSYM SDL_RemoveTimer}
  2020. function SDL_SetTimer(interval: UInt32; callback: TSDL_TimerCallback): Integer;
  2021. cdecl; external {$IFDEF __GPC__}name 'SDL_SetTimer'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2022. {$EXTERNALSYM SDL_SetTimer}
  2023. {------------------------------------------------------------------------------}
  2024. { audio-routines }
  2025. {------------------------------------------------------------------------------}
  2026. { These functions are used internally, and should not be used unless you
  2027. have a specific need to specify the audio driver you want to use.
  2028. You should normally use SDL_Init() or SDL_InitSubSystem(). }
  2029. function SDL_AudioInit(driver_name: PChar): Integer;
  2030. cdecl; external {$IFDEF __GPC__}name 'SDL_AudioInit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2031. {$EXTERNALSYM SDL_AudioInit}
  2032. procedure SDL_AudioQuit;
  2033. cdecl; external {$IFDEF __GPC__}name 'SDL_AudioQuit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2034. {$EXTERNALSYM SDL_AudioQuit}
  2035. { This function fills the given character buffer with the name of the
  2036. current audio driver, and returns a Pointer to it if the audio driver has
  2037. been initialized. It returns NULL if no driver has been initialized. }
  2038. function SDL_AudioDriverName(namebuf: PChar; maxlen: Integer): PChar;
  2039. cdecl; external {$IFDEF __GPC__}name 'SDL_AudioDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2040. {$EXTERNALSYM SDL_AudioDriverName}
  2041. { This function opens the audio device with the desired parameters, and
  2042. returns 0 if successful, placing the actual hardware parameters in the
  2043. structure pointed to by 'obtained'. If 'obtained' is NULL, the audio
  2044. data passed to the callback function will be guaranteed to be in the
  2045. requested format, and will be automatically converted to the hardware
  2046. audio format if necessary. This function returns -1 if it failed
  2047. to open the audio device, or couldn't set up the audio thread.
  2048. When filling in the desired audio spec structure,
  2049. 'desired->freq' should be the desired audio frequency in samples-per-second.
  2050. 'desired->format' should be the desired audio format.
  2051. 'desired->samples' is the desired size of the audio buffer, in samples.
  2052. This number should be a power of two, and may be adjusted by the audio
  2053. driver to a value more suitable for the hardware. Good values seem to
  2054. range between 512 and 8096 inclusive, depending on the application and
  2055. CPU speed. Smaller values yield faster response time, but can lead
  2056. to underflow if the application is doing heavy processing and cannot
  2057. fill the audio buffer in time. A stereo sample consists of both right
  2058. and left channels in LR ordering.
  2059. Note that the number of samples is directly related to time by the
  2060. following formula: ms = (samples*1000)/freq
  2061. 'desired->size' is the size in bytes of the audio buffer, and is
  2062. calculated by SDL_OpenAudio().
  2063. 'desired->silence' is the value used to set the buffer to silence,
  2064. and is calculated by SDL_OpenAudio().
  2065. 'desired->callback' should be set to a function that will be called
  2066. when the audio device is ready for more data. It is passed a pointer
  2067. to the audio buffer, and the length in bytes of the audio buffer.
  2068. This function usually runs in a separate thread, and so you should
  2069. protect data structures that it accesses by calling SDL_LockAudio()
  2070. and SDL_UnlockAudio() in your code.
  2071. 'desired->userdata' is passed as the first parameter to your callback
  2072. function.
  2073. The audio device starts out playing silence when it's opened, and should
  2074. be enabled for playing by calling SDL_PauseAudio(0) when you are ready
  2075. for your audio callback function to be called. Since the audio driver
  2076. may modify the requested size of the audio buffer, you should allocate
  2077. any local mixing buffers after you open the audio device. }
  2078. function SDL_OpenAudio(desired, obtained: PSDL_AudioSpec): Integer;
  2079. cdecl; external {$IFDEF __GPC__}name 'SDL_OpenAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2080. {$EXTERNALSYM SDL_OpenAudio}
  2081. { Get the current audio state: }
  2082. function SDL_GetAudioStatus: TSDL_Audiostatus;
  2083. cdecl; external {$IFDEF __GPC__}name 'SDL_GetAudioStatus'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2084. {$EXTERNALSYM SDL_GetAudioStatus}
  2085. { This function pauses and unpauses the audio callback processing.
  2086. It should be called with a parameter of 0 after opening the audio
  2087. device to start playing sound. This is so you can safely initialize
  2088. data for your callback function after opening the audio device.
  2089. Silence will be written to the audio device during the pause. }
  2090. procedure SDL_PauseAudio(pause_on: Integer);
  2091. cdecl; external {$IFDEF __GPC__}name 'SDL_PauseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2092. {$EXTERNALSYM SDL_PauseAudio}
  2093. { This function loads a WAVE from the data source, automatically freeing
  2094. that source if 'freesrc' is non-zero. For example, to load a WAVE file,
  2095. you could do:
  2096. SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
  2097. If this function succeeds, it returns the given SDL_AudioSpec,
  2098. filled with the audio data format of the wave data, and sets
  2099. 'audio_buf' to a malloc()'d buffer containing the audio data,
  2100. and sets 'audio_len' to the length of that audio buffer, in bytes.
  2101. You need to free the audio buffer with SDL_FreeWAV() when you are
  2102. done with it.
  2103. This function returns NULL and sets the SDL error message if the
  2104. wave file cannot be opened, uses an unknown data format, or is
  2105. corrupt. Currently raw and MS-ADPCM WAVE files are supported. }
  2106. function SDL_LoadWAV_RW(src: PSDL_RWops; freesrc: Integer; spec:
  2107. PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
  2108. cdecl; external {$IFDEF __GPC__}name 'SDL_LoadWAV_RW'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2109. {$EXTERNALSYM SDL_LoadWAV_RW}
  2110. // Compatibility convenience function -- loads a WAV from a file
  2111. function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf:
  2112. PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
  2113. {$EXTERNALSYM SDL_LoadWAV}
  2114. { This function frees data previously allocated with SDL_LoadWAV_RW() }
  2115. procedure SDL_FreeWAV(audio_buf: PUInt8);
  2116. cdecl; external {$IFDEF __GPC__}name 'SDL_FreeWAV'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2117. {$EXTERNALSYM SDL_FreeWAV}
  2118. { This function takes a source format and rate and a destination format
  2119. and rate, and initializes the 'cvt' structure with information needed
  2120. by SDL_ConvertAudio() to convert a buffer of audio data from one format
  2121. to the other.
  2122. This function returns 0, or -1 if there was an error. }
  2123. function SDL_BuildAudioCVT(cvt: PSDL_AudioCVT; src_format: UInt16;
  2124. src_channels: UInt8; src_rate: Integer; dst_format: UInt16; dst_channels: UInt8;
  2125. dst_rate: Integer): Integer;
  2126. cdecl; external {$IFDEF __GPC__}name 'SDL_BuildAudioCVT'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2127. {$EXTERNALSYM SDL_BuildAudioCVT}
  2128. { Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
  2129. created an audio buffer cvt->buf, and filled it with cvt->len bytes of
  2130. audio data in the source format, this function will convert it in-place
  2131. to the desired format.
  2132. The data conversion may expand the size of the audio data, so the buffer
  2133. cvt->buf should be allocated after the cvt structure is initialized by
  2134. SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. }
  2135. function SDL_ConvertAudio(cvt: PSDL_AudioCVT): Integer;
  2136. cdecl; external {$IFDEF __GPC__}name 'SDL_ConvertAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2137. {$EXTERNALSYM SDL_ConvertAudio}
  2138. { This takes two audio buffers of the playing audio format and mixes
  2139. them, performing addition, volume adjustment, and overflow clipping.
  2140. The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
  2141. for full audio volume. Note this does not change hardware volume.
  2142. This is provided for convenience -- you can mix your own audio data. }
  2143. procedure SDL_MixAudio(dst, src: PUInt8; len: UInt32; volume: Integer);
  2144. cdecl; external {$IFDEF __GPC__}name 'SDL_MixAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2145. {$EXTERNALSYM SDL_MixAudio}
  2146. { The lock manipulated by these functions protects the callback function.
  2147. During a LockAudio/UnlockAudio pair, you can be guaranteed that the
  2148. callback function is not running. Do not call these from the callback
  2149. function or you will cause deadlock. }
  2150. procedure SDL_LockAudio;
  2151. cdecl; external {$IFDEF __GPC__}name 'SDL_LockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2152. {$EXTERNALSYM SDL_LockAudio}
  2153. procedure SDL_UnlockAudio;
  2154. cdecl; external {$IFDEF __GPC__}name 'SDL_UnlockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2155. {$EXTERNALSYM SDL_UnlockAudio}
  2156. { This function shuts down audio processing and closes the audio device. }
  2157. procedure SDL_CloseAudio;
  2158. cdecl; external {$IFDEF __GPC__}name 'SDL_CloseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2159. {$EXTERNALSYM SDL_CloseAudio}
  2160. {------------------------------------------------------------------------------}
  2161. { CD-routines }
  2162. {------------------------------------------------------------------------------}
  2163. { Returns the number of CD-ROM drives on the system, or -1 if
  2164. SDL_Init() has not been called with the SDL_INIT_CDROM flag. }
  2165. function SDL_CDNumDrives: Integer;
  2166. cdecl; external {$IFDEF __GPC__}name 'SDL_CDNumDrives'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2167. {$EXTERNALSYM SDL_CDNumDrives}
  2168. { Returns a human-readable, system-dependent identifier for the CD-ROM.
  2169. Example:
  2170. "/dev/cdrom"
  2171. "E:"
  2172. "/dev/disk/ide/1/master" }
  2173. function SDL_CDName(drive: Integer): PChar;
  2174. cdecl; external {$IFDEF __GPC__}name 'SDL_CDName'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2175. {$EXTERNALSYM SDL_CDName}
  2176. { Opens a CD-ROM drive for access. It returns a drive handle on success,
  2177. or NULL if the drive was invalid or busy. This newly opened CD-ROM
  2178. becomes the default CD used when other CD functions are passed a NULL
  2179. CD-ROM handle.
  2180. Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. }
  2181. function SDL_CDOpen(drive: Integer): PSDL_CD;
  2182. cdecl; external {$IFDEF __GPC__}name 'SDL_CDOpen'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2183. {$EXTERNALSYM SDL_CDOpen}
  2184. { This function returns the current status of the given drive.
  2185. If the drive has a CD in it, the table of contents of the CD and current
  2186. play position of the CD will be stored in the SDL_CD structure. }
  2187. function SDL_CDStatus(cdrom: PSDL_CD): TSDL_CDStatus;
  2188. cdecl; external {$IFDEF __GPC__}name 'SDL_CDStatus'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2189. {$EXTERNALSYM SDL_CDStatus}
  2190. { Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
  2191. tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
  2192. until the end of the CD. This function will skip data tracks.
  2193. This function should only be called after calling SDL_CDStatus() to
  2194. get track information about the CD.
  2195. For example:
  2196. // Play entire CD:
  2197. if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
  2198. SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
  2199. // Play last track:
  2200. if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
  2201. begin
  2202. SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
  2203. end;
  2204. // Play first and second track and 10 seconds of third track:
  2205. if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
  2206. SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
  2207. This function returns 0, or -1 if there was an error. }
  2208. function SDL_CDPlayTracks(cdrom: PSDL_CD; start_track: Integer; start_frame:
  2209. Integer; ntracks: Integer; nframes: Integer): Integer;
  2210. cdecl; external {$IFDEF __GPC__}name 'SDL_CDPlayTracks'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2211. {$EXTERNALSYM SDL_CDPlayTracks}
  2212. { Play the given CD starting at 'start' frame for 'length' frames.
  2213. It returns 0, or -1 if there was an error. }
  2214. function SDL_CDPlay(cdrom: PSDL_CD; start: Integer; length: Integer): Integer;
  2215. cdecl; external {$IFDEF __GPC__}name 'SDL_CDPlay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2216. {$EXTERNALSYM SDL_CDPlay}
  2217. // Pause play -- returns 0, or -1 on error
  2218. function SDL_CDPause(cdrom: PSDL_CD): Integer;
  2219. cdecl; external {$IFDEF __GPC__}name 'SDL_CDPause'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2220. {$EXTERNALSYM SDL_CDPause}
  2221. // Resume play -- returns 0, or -1 on error
  2222. function SDL_CDResume(cdrom: PSDL_CD): Integer;
  2223. cdecl; external {$IFDEF __GPC__}name 'SDL_CDResume'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2224. {$EXTERNALSYM SDL_CDResume}
  2225. // Stop play -- returns 0, or -1 on error
  2226. function SDL_CDStop(cdrom: PSDL_CD): Integer;
  2227. cdecl; external {$IFDEF __GPC__}name 'SDL_CDStop'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2228. {$EXTERNALSYM SDL_CDStop}
  2229. // Eject CD-ROM -- returns 0, or -1 on error
  2230. function SDL_CDEject(cdrom: PSDL_CD): Integer;
  2231. cdecl; external {$IFDEF __GPC__}name 'SDL_CDEject'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2232. {$EXTERNALSYM SDL_CDEject}
  2233. // Closes the handle for the CD-ROM drive
  2234. procedure SDL_CDClose(cdrom: PSDL_CD);
  2235. cdecl; external {$IFDEF __GPC__}name 'SDL_CDClose'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2236. {$EXTERNALSYM SDL_CDClose}
  2237. // Given a status, returns true if there's a disk in the drive
  2238. function SDL_CDInDrive( status : TSDL_CDStatus ) : LongBool;
  2239. {$EXTERNALSYM SDL_CDInDrive}
  2240. // Conversion functions from frames to Minute/Second/Frames and vice versa
  2241. procedure FRAMES_TO_MSF(frames: Integer; var M: Integer; var S: Integer; var
  2242. F: Integer);
  2243. {$EXTERNALSYM FRAMES_TO_MSF}
  2244. function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer;
  2245. {$EXTERNALSYM MSF_TO_FRAMES}
  2246. {------------------------------------------------------------------------------}
  2247. { JoyStick-routines }
  2248. {------------------------------------------------------------------------------}
  2249. { Count the number of joysticks attached to the system }
  2250. function SDL_NumJoysticks: Integer;
  2251. cdecl; external {$IFDEF __GPC__}name 'SDL_NumJoysticks'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2252. {$EXTERNALSYM SDL_NumJoysticks}
  2253. { Get the implementation dependent name of a joystick.
  2254. This can be called before any joysticks are opened.
  2255. If no name can be found, this function returns NULL. }
  2256. function SDL_JoystickName(index: Integer): PChar;
  2257. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickName'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2258. {$EXTERNALSYM SDL_JoystickName}
  2259. { Open a joystick for use - the index passed as an argument refers to
  2260. the N'th joystick on the system. This index is the value which will
  2261. identify this joystick in future joystick events.
  2262. This function returns a joystick identifier, or NULL if an error occurred. }
  2263. function SDL_JoystickOpen(index: Integer): PSDL_Joystick;
  2264. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickOpen'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2265. {$EXTERNALSYM SDL_JoystickOpen}
  2266. { Returns 1 if the joystick has been opened, or 0 if it has not. }
  2267. function SDL_JoystickOpened(index: Integer): Integer;
  2268. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickOpened'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2269. {$EXTERNALSYM SDL_JoystickOpened}
  2270. { Get the device index of an opened joystick. }
  2271. function SDL_JoystickIndex(joystick: PSDL_Joystick): Integer;
  2272. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickIndex'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2273. {$EXTERNALSYM SDL_JoystickIndex}
  2274. { Get the number of general axis controls on a joystick }
  2275. function SDL_JoystickNumAxes(joystick: PSDL_Joystick): Integer;
  2276. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumAxes'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2277. {$EXTERNALSYM SDL_JoystickNumAxes}
  2278. { Get the number of trackballs on a joystick
  2279. Joystick trackballs have only relative motion events associated
  2280. with them and their state cannot be polled. }
  2281. function SDL_JoystickNumBalls(joystick: PSDL_Joystick): Integer;
  2282. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumBalls'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2283. {$EXTERNALSYM SDL_JoystickNumBalls}
  2284. { Get the number of POV hats on a joystick }
  2285. function SDL_JoystickNumHats(joystick: PSDL_Joystick): Integer;
  2286. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumHats'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2287. {$EXTERNALSYM SDL_JoystickNumHats}
  2288. { Get the number of buttons on a joystick }
  2289. function SDL_JoystickNumButtons(joystick: PSDL_Joystick): Integer;
  2290. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumButtons'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2291. {$EXTERNALSYM SDL_JoystickNumButtons}
  2292. { Update the current state of the open joysticks.
  2293. This is called automatically by the event loop if any joystick
  2294. events are enabled. }
  2295. procedure SDL_JoystickUpdate;
  2296. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickUpdate'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2297. {$EXTERNALSYM SDL_JoystickUpdate;}
  2298. { Enable/disable joystick event polling.
  2299. If joystick events are disabled, you must call SDL_JoystickUpdate()
  2300. yourself and check the state of the joystick when you want joystick
  2301. information.
  2302. The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. }
  2303. function SDL_JoystickEventState(state: Integer): Integer;
  2304. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickEventState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2305. {$EXTERNALSYM SDL_JoystickEventState}
  2306. { Get the current state of an axis control on a joystick
  2307. The state is a value ranging from -32768 to 32767.
  2308. The axis indices start at index 0. }
  2309. function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: Integer) : SInt16;
  2310. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetAxis'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2311. {$EXTERNALSYM SDL_JoystickGetAxis}
  2312. { The hat indices start at index 0. }
  2313. function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: Integer): UInt8;
  2314. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetHat'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2315. {$EXTERNALSYM SDL_JoystickGetHat}
  2316. { Get the ball axis change since the last poll
  2317. This returns 0, or -1 if you passed it invalid parameters.
  2318. The ball indices start at index 0. }
  2319. function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: Integer; var dx: Integer; var dy: Integer): Integer;
  2320. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetBall'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2321. {$EXTERNALSYM SDL_JoystickGetBall}
  2322. { Get the current state of a button on a joystick
  2323. The button indices start at index 0. }
  2324. function SDL_JoystickGetButton( joystick: PSDL_Joystick; Button: Integer): UInt8;
  2325. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetButton'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2326. {$EXTERNALSYM SDL_JoystickGetButton}
  2327. { Close a joystick previously opened with SDL_JoystickOpen() }
  2328. procedure SDL_JoystickClose(joystick: PSDL_Joystick);
  2329. cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickClose'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2330. {$EXTERNALSYM SDL_JoystickClose}
  2331. {------------------------------------------------------------------------------}
  2332. { event-handling }
  2333. {------------------------------------------------------------------------------}
  2334. { Pumps the event loop, gathering events from the input devices.
  2335. This function updates the event queue and internal input device state.
  2336. This should only be run in the thread that sets the video mode. }
  2337. procedure SDL_PumpEvents;
  2338. cdecl; external {$IFDEF __GPC__}name 'SDL_PumpEvents'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2339. {$EXTERNALSYM SDL_PumpEvents;}
  2340. { Checks the event queue for messages and optionally returns them.
  2341. If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
  2342. the back of the event queue.
  2343. If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
  2344. of the event queue, matching 'mask', will be returned and will not
  2345. be removed from the queue.
  2346. If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
  2347. of the event queue, matching 'mask', will be returned and will be
  2348. removed from the queue.
  2349. This function returns the number of events actually stored, or -1
  2350. if there was an error. This function is thread-safe. }
  2351. function SDL_PeepEvents(events: PSDL_Event; numevents: Integer; action: TSDL_eventaction; mask: UInt32): Integer;
  2352. cdecl; external {$IFDEF __GPC__}name 'SDL_PeepEvents'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2353. {$EXTERNALSYM SDL_PeepEvents}
  2354. { Polls for currently pending events, and returns 1 if there are any pending
  2355. events, or 0 if there are none available. If 'event' is not NULL, the next
  2356. event is removed from the queue and stored in that area. }
  2357. function SDL_PollEvent(event: PSDL_Event): Integer;
  2358. cdecl; external {$IFDEF __GPC__}name 'SDL_PollEvent'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2359. {$EXTERNALSYM SDL_PollEvent}
  2360. { Waits indefinitely for the next available event, returning 1, or 0 if there
  2361. was an error while waiting for events. If 'event' is not NULL, the next
  2362. event is removed from the queue and stored in that area. }
  2363. function SDL_WaitEvent(event: PSDL_Event): Integer;
  2364. cdecl; external {$IFDEF __GPC__}name 'SDL_WaitEvent'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2365. {$EXTERNALSYM SDL_WaitEvent}
  2366. function SDL_PushEvent( event : PSDL_Event ) : Integer;
  2367. cdecl; external {$IFDEF __GPC__}name 'SDL_PushEvent'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2368. {$EXTERNALSYM SDL_PushEvent}
  2369. { If the filter returns 1, then the event will be added to the internal queue.
  2370. If it returns 0, then the event will be dropped from the queue, but the
  2371. internal state will still be updated. This allows selective filtering of
  2372. dynamically arriving events.
  2373. WARNING: Be very careful of what you do in the event filter function, as
  2374. it may run in a different thread!
  2375. There is one caveat when dealing with the SDL_QUITEVENT event type. The
  2376. event filter is only called when the window manager desires to close the
  2377. application window. If the event filter returns 1, then the window will
  2378. be closed, otherwise the window will remain open if possible.
  2379. If the quit event is generated by an interrupt signal, it will bypass the
  2380. internal queue and be delivered to the application at the next event poll. }
  2381. procedure SDL_SetEventFilter( filter : TSDL_EventFilter );
  2382. cdecl; external {$IFDEF __GPC__}name 'SDL_SetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2383. {$EXTERNALSYM SDL_SetEventFilter}
  2384. { Return the current event filter - can be used to "chain" filters.
  2385. If there is no event filter set, this function returns NULL. }
  2386. function SDL_GetEventFilter: TSDL_EventFilter;
  2387. cdecl; external {$IFDEF __GPC__}name 'SDL_GetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2388. {$EXTERNALSYM SDL_GetEventFilter}
  2389. { This function allows you to set the state of processing certain events.
  2390. If 'state' is set to SDL_IGNORE, that event will be automatically dropped
  2391. from the event queue and will not event be filtered.
  2392. If 'state' is set to SDL_ENABLE, that event will be processed normally.
  2393. If 'state' is set to SDL_QUERY, SDL_EventState() will return the
  2394. current processing state of the specified event. }
  2395. function SDL_EventState(type_: UInt8; state: Integer): UInt8;
  2396. cdecl; external {$IFDEF __GPC__}name 'SDL_EventState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2397. {$EXTERNALSYM SDL_EventState}
  2398. {------------------------------------------------------------------------------}
  2399. { Version Routines }
  2400. {------------------------------------------------------------------------------}
  2401. { This macro can be used to fill a version structure with the compile-time
  2402. version of the SDL library. }
  2403. procedure SDL_VERSION(var X: TSDL_Version);
  2404. {$EXTERNALSYM SDL_VERSION}
  2405. { This macro turns the version numbers into a numeric value:
  2406. (1,2,3) -> (1203)
  2407. This assumes that there will never be more than 100 patchlevels }
  2408. function SDL_VERSIONNUM(X, Y, Z: Integer): Integer;
  2409. {$EXTERNALSYM SDL_VERSIONNUM}
  2410. // This is the version number macro for the current SDL version
  2411. function SDL_COMPILEDVERSION: Integer;
  2412. {$EXTERNALSYM SDL_COMPILEDVERSION}
  2413. // This macro will evaluate to true if compiled with SDL at least X.Y.Z
  2414. function SDL_VERSION_ATLEAST(X: Integer; Y: Integer; Z: Integer) : LongBool;
  2415. {$EXTERNALSYM SDL_VERSION_ATLEAST}
  2416. { This function gets the version of the dynamically linked SDL library.
  2417. it should NOT be used to fill a version structure, instead you should
  2418. use the SDL_Version() macro. }
  2419. function SDL_Linked_Version: PSDL_version;
  2420. cdecl; external {$IFDEF __GPC__}name 'SDL_Linked_Version'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2421. {$EXTERNALSYM SDL_Linked_Version}
  2422. {------------------------------------------------------------------------------}
  2423. { video }
  2424. {------------------------------------------------------------------------------}
  2425. { These functions are used internally, and should not be used unless you
  2426. have a specific need to specify the video driver you want to use.
  2427. You should normally use SDL_Init() or SDL_InitSubSystem().
  2428. SDL_VideoInit() initializes the video subsystem -- sets up a connection
  2429. to the window manager, etc, and determines the current video mode and
  2430. pixel format, but does not initialize a window or graphics mode.
  2431. Note that event handling is activated by this routine.
  2432. If you use both sound and video in your application, you need to call
  2433. SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
  2434. you won't be able to set full-screen display modes. }
  2435. function SDL_VideoInit(driver_name: PChar; flags: UInt32): Integer;
  2436. cdecl; external {$IFDEF __GPC__}name 'SDL_VideoInit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2437. {$EXTERNALSYM SDL_VideoInit}
  2438. procedure SDL_VideoQuit;
  2439. cdecl; external {$IFDEF __GPC__}name 'SDL_VideoQuit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2440. {$EXTERNALSYM SDL_VideoQuit}
  2441. { This function fills the given character buffer with the name of the
  2442. video driver, and returns a pointer to it if the video driver has
  2443. been initialized. It returns NULL if no driver has been initialized. }
  2444. function SDL_VideoDriverName(namebuf: PChar; maxlen: Integer): PChar;
  2445. cdecl; external {$IFDEF __GPC__}name 'SDL_VideoDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2446. {$EXTERNALSYM SDL_VideoDriverName}
  2447. { This function returns a pointer to the current display surface.
  2448. If SDL is doing format conversion on the display surface, this
  2449. function returns the publicly visible surface, not the real video
  2450. surface. }
  2451. function SDL_GetVideoSurface: PSDL_Surface;
  2452. cdecl; external {$IFDEF __GPC__}name 'SDL_GetVideoSurface'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2453. {$EXTERNALSYM SDL_GetVideoSurface}
  2454. { This function returns a read-only pointer to information about the
  2455. video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt'
  2456. member of the returned structure will contain the pixel format of the
  2457. "best" video mode. }
  2458. function SDL_GetVideoInfo: PSDL_VideoInfo;
  2459. cdecl; external {$IFDEF __GPC__}name 'SDL_GetVideoInfo'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2460. {$EXTERNALSYM SDL_GetVideoInfo}
  2461. { Check to see if a particular video mode is supported.
  2462. It returns 0 if the requested mode is not supported under any bit depth,
  2463. or returns the bits-per-pixel of the closest available mode with the
  2464. given width and height. If this bits-per-pixel is different from the
  2465. one used when setting the video mode, SDL_SetVideoMode() will succeed,
  2466. but will emulate the requested bits-per-pixel with a shadow surface.
  2467. The arguments to SDL_VideoModeOK() are the same ones you would pass to
  2468. SDL_SetVideoMode() }
  2469. function SDL_VideoModeOK(width, height, bpp: Integer; flags: UInt32): Integer;
  2470. cdecl; external {$IFDEF __GPC__}name 'SDL_VideoModeOK'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2471. {$EXTERNALSYM SDL_VideoModeOK}
  2472. { Return a pointer to an array of available screen dimensions for the
  2473. given format and video flags, sorted largest to smallest. Returns
  2474. NULL if there are no dimensions available for a particular format,
  2475. or (SDL_Rect **)-1 if any dimension is okay for the given format.
  2476. if 'format' is NULL, the mode list will be for the format given
  2477. by SDL_GetVideoInfo( ) - > vfmt }
  2478. function SDL_ListModes(format: PSDL_PixelFormat; flags: UInt32): PPSDL_Rect;
  2479. cdecl; external {$IFDEF __GPC__}name 'SDL_ListModes'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2480. {$EXTERNALSYM SDL_ListModes}
  2481. { Set up a video mode with the specified width, height and bits-per-pixel.
  2482. If 'bpp' is 0, it is treated as the current display bits per pixel.
  2483. If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
  2484. requested bits-per-pixel, but will return whatever video pixel format is
  2485. available. The default is to emulate the requested pixel format if it
  2486. is not natively available.
  2487. If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
  2488. video memory, if possible, and you may have to call SDL_LockSurface()
  2489. in order to access the raw framebuffer. Otherwise, the video surface
  2490. will be created in system memory.
  2491. If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
  2492. updates asynchronously, but you must always lock before accessing pixels.
  2493. SDL will wait for updates to complete before returning from the lock.
  2494. If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
  2495. that the colors set by SDL_SetColors() will be the colors you get.
  2496. Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
  2497. of the colors exactly the way they are requested, and you should look
  2498. at the video surface structure to determine the actual palette.
  2499. If SDL cannot guarantee that the colors you request can be set,
  2500. i.e. if the colormap is shared, then the video surface may be created
  2501. under emulation in system memory, overriding the SDL_HWSURFACE flag.
  2502. If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
  2503. a fullscreen video mode. The default is to create a windowed mode
  2504. if the current graphics system has a window manager.
  2505. If the SDL library is able to set a fullscreen video mode, this flag
  2506. will be set in the surface that is returned.
  2507. If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
  2508. two surfaces in video memory and swap between them when you call
  2509. SDL_Flip(). This is usually slower than the normal single-buffering
  2510. scheme, but prevents "tearing" artifacts caused by modifying video
  2511. memory while the monitor is refreshing. It should only be used by
  2512. applications that redraw the entire screen on every update.
  2513. This function returns the video framebuffer surface, or NULL if it fails. }
  2514. function SDL_SetVideoMode(width, height, bpp: Integer; flags: UInt32): PSDL_Surface;
  2515. cdecl; external {$IFDEF __GPC__}name 'SDL_SetVideoMode'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2516. {$EXTERNALSYM SDL_SetVideoMode}
  2517. { Makes sure the given list of rectangles is updated on the given screen.
  2518. If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
  2519. screen.
  2520. These functions should not be called while 'screen' is locked. }
  2521. procedure SDL_UpdateRects(screen: PSDL_Surface; numrects: Integer; rects: PSDL_Rect);
  2522. cdecl; external {$IFDEF __GPC__}name 'SDL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2523. {$EXTERNALSYM SDL_UpdateRects}
  2524. procedure SDL_UpdateRect(screen: PSDL_Surface; x, y: SInt32; w, h: UInt32);
  2525. cdecl; external {$IFDEF __GPC__}name 'SDL_UpdateRect'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2526. {$EXTERNALSYM SDL_UpdateRect}
  2527. { On hardware that supports double-buffering, this function sets up a flip
  2528. and returns. The hardware will wait for vertical retrace, and then swap
  2529. video buffers before the next video surface blit or lock will return.
  2530. On hardware that doesn not support double-buffering, this is equivalent
  2531. to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
  2532. The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
  2533. setting the video mode for this function to perform hardware flipping.
  2534. This function returns 0 if successful, or -1 if there was an error.}
  2535. function SDL_Flip(screen: PSDL_Surface): Integer;
  2536. cdecl; external {$IFDEF __GPC__}name 'SDL_Flip'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2537. {$EXTERNALSYM SDL_Flip}
  2538. { Set the gamma correction for each of the color channels.
  2539. The gamma values range (approximately) between 0.1 and 10.0
  2540. If this function isn't supported directly by the hardware, it will
  2541. be emulated using gamma ramps, if available. If successful, this
  2542. function returns 0, otherwise it returns -1. }
  2543. function SDL_SetGamma(redgamma: single; greengamma: single; bluegamma: single ): Integer;
  2544. cdecl; external {$IFDEF __GPC__}name 'SDL_SetGamma'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2545. {$EXTERNALSYM SDL_SetGamma}
  2546. { Set the gamma translation table for the red, green, and blue channels
  2547. of the video hardware. Each table is an array of 256 16-bit quantities,
  2548. representing a mapping between the input and output for that channel.
  2549. The input is the index into the array, and the output is the 16-bit
  2550. gamma value at that index, scaled to the output color precision.
  2551. You may pass NULL for any of the channels to leave it unchanged.
  2552. If the call succeeds, it will return 0. If the display driver or
  2553. hardware does not support gamma translation, or otherwise fails,
  2554. this function will return -1. }
  2555. function SDL_SetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer;
  2556. cdecl; external {$IFDEF __GPC__}name 'SDL_SetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2557. {$EXTERNALSYM SDL_SetGammaRamp}
  2558. { Retrieve the current values of the gamma translation tables.
  2559. You must pass in valid pointers to arrays of 256 16-bit quantities.
  2560. Any of the pointers may be NULL to ignore that channel.
  2561. If the call succeeds, it will return 0. If the display driver or
  2562. hardware does not support gamma translation, or otherwise fails,
  2563. this function will return -1. }
  2564. function SDL_GetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer;
  2565. cdecl; external {$IFDEF __GPC__}name 'SDL_GetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2566. {$EXTERNALSYM SDL_GetGammaRamp}
  2567. { Sets a portion of the colormap for the given 8-bit surface. If 'surface'
  2568. is not a palettized surface, this function does nothing, returning 0.
  2569. If all of the colors were set as passed to SDL_SetColors(), it will
  2570. return 1. If not all the color entries were set exactly as given,
  2571. it will return 0, and you should look at the surface palette to
  2572. determine the actual color palette.
  2573. When 'surface' is the surface associated with the current display, the
  2574. display colormap will be updated with the requested colors. If
  2575. SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
  2576. will always return 1, and the palette is guaranteed to be set the way
  2577. you desire, even if the window colormap has to be warped or run under
  2578. emulation. }
  2579. function SDL_GetPixel(Surface: PSDL_Surface; const x, y: integer): SInt32; {$ifdef fpc} inline; {$endif}
  2580. procedure SDL_PutPixel(Surface: PSDL_Surface; const x, y: integer; pixel: UInt32); {$ifdef fpc} inline; {$endif}
  2581. function SDL_SetColors(surface: PSDL_Surface; colors: PSDL_Color; firstcolor : Integer; ncolors: Integer) : Integer;
  2582. cdecl; external {$IFDEF __GPC__}name 'SDL_SetColors'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2583. {$EXTERNALSYM SDL_SetColors}
  2584. { Sets a portion of the colormap for a given 8-bit surface.
  2585. 'flags' is one or both of:
  2586. SDL_LOGPAL -- set logical palette, which controls how blits are mapped
  2587. to/from the surface,
  2588. SDL_PHYSPAL -- set physical palette, which controls how pixels look on
  2589. the screen
  2590. Only screens have physical palettes. Separate change of physical/logical
  2591. palettes is only possible if the screen has SDL_HWPALETTE set.
  2592. The return value is 1 if all colours could be set as requested, and 0
  2593. otherwise.
  2594. SDL_SetColors() is equivalent to calling this function with
  2595. flags = (SDL_LOGPAL or SDL_PHYSPAL). }
  2596. function SDL_SetPalette(surface: PSDL_Surface; flags: Integer; colors: PSDL_Color; firstcolor: Integer; ncolors: Integer): Integer;
  2597. cdecl; external {$IFDEF __GPC__}name 'SDL_SetPalette'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2598. {$EXTERNALSYM SDL_SetPalette}
  2599. { Maps an RGB triple to an opaque pixel value for a given pixel format }
  2600. function SDL_MapRGB(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8) : UInt32;
  2601. cdecl; external {$IFDEF __GPC__}name 'SDL_MapRGB'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2602. {$EXTERNALSYM SDL_MapRGB}
  2603. { Maps an RGBA quadruple to a pixel value for a given pixel format }
  2604. function SDL_MapRGBA(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8; a: UInt8): UInt32;
  2605. cdecl; external {$IFDEF __GPC__}name 'SDL_MapRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2606. {$EXTERNALSYM SDL_MapRGBA}
  2607. { Maps a pixel value into the RGB components for a given pixel format }
  2608. procedure SDL_GetRGB(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8);
  2609. cdecl; external {$IFDEF __GPC__}name 'SDL_GetRGB'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2610. {$EXTERNALSYM SDL_GetRGB}
  2611. { Maps a pixel value into the RGBA components for a given pixel format }
  2612. procedure SDL_GetRGBA(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8; a: PUInt8);
  2613. cdecl; external {$IFDEF __GPC__}name 'SDL_GetRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2614. {$EXTERNALSYM SDL_GetRGBA}
  2615. { Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
  2616. If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
  2617. If the depth is greater than 8 bits, the pixel format is set using the
  2618. flags '[RGB]mask'.
  2619. If the function runs out of memory, it will return NULL.
  2620. The 'flags' tell what kind of surface to create.
  2621. SDL_SWSURFACE means that the surface should be created in system memory.
  2622. SDL_HWSURFACE means that the surface should be created in video memory,
  2623. with the same format as the display surface. This is useful for surfaces
  2624. that will not change much, to take advantage of hardware acceleration
  2625. when being blitted to the display surface.
  2626. SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
  2627. this surface, but you must always lock it before accessing the pixels.
  2628. SDL will wait for current blits to finish before returning from the lock.
  2629. SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
  2630. If the hardware supports acceleration of colorkey blits between
  2631. two surfaces in video memory, SDL will try to place the surface in
  2632. video memory. If this isn't possible or if there is no hardware
  2633. acceleration available, the surface will be placed in system memory.
  2634. SDL_SRCALPHA means that the surface will be used for alpha blits and
  2635. if the hardware supports hardware acceleration of alpha blits between
  2636. two surfaces in video memory, to place the surface in video memory
  2637. if possible, otherwise it will be placed in system memory.
  2638. If the surface is created in video memory, blits will be _much_ faster,
  2639. but the surface format must be identical to the video surface format,
  2640. and the only way to access the pixels member of the surface is to use
  2641. the SDL_LockSurface() and SDL_UnlockSurface() calls.
  2642. If the requested surface actually resides in video memory, SDL_HWSURFACE
  2643. will be set in the flags member of the returned surface. If for some
  2644. reason the surface could not be placed in video memory, it will not have
  2645. the SDL_HWSURFACE flag set, and will be created in system memory instead. }
  2646. function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer;
  2647. RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
  2648. {$EXTERNALSYM SDL_AllocSurface}
  2649. function SDL_CreateRGBSurface(flags: UInt32; width, height, depth: Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
  2650. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateRGBSurface'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2651. {$EXTERNALSYM SDL_CreateRGBSurface}
  2652. function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch
  2653. : Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
  2654. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateRGBSurfaceFrom'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2655. {$EXTERNALSYM SDL_CreateRGBSurfaceFrom}
  2656. procedure SDL_FreeSurface(surface: PSDL_Surface);
  2657. cdecl; external {$IFDEF __GPC__}name 'SDL_FreeSurface'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2658. {$EXTERNALSYM SDL_FreeSurface}
  2659. function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  2660. {$EXTERNALSYM SDL_MustLock}
  2661. { SDL_LockSurface() sets up a surface for directly accessing the pixels.
  2662. Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
  2663. to and read from 'surface->pixels', using the pixel format stored in
  2664. 'surface->format'. Once you are done accessing the surface, you should
  2665. use SDL_UnlockSurface() to release it.
  2666. Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
  2667. to 0, then you can read and write to the surface at any time, and the
  2668. pixel format of the surface will not change. In particular, if the
  2669. SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
  2670. will not need to lock the display surface before accessing it.
  2671. No operating system or library calls should be made between lock/unlock
  2672. pairs, as critical system locks may be held during this time.
  2673. SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. }
  2674. function SDL_LockSurface(surface: PSDL_Surface): Integer;
  2675. cdecl; external {$IFDEF __GPC__}name 'SDL_LockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2676. {$EXTERNALSYM SDL_LockSurface}
  2677. procedure SDL_UnlockSurface(surface: PSDL_Surface);
  2678. cdecl; external {$IFDEF __GPC__}name 'SDL_UnlockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2679. {$EXTERNALSYM SDL_UnlockSurface}
  2680. { Load a surface from a seekable SDL data source (memory or file.)
  2681. If 'freesrc' is non-zero, the source will be closed after being read.
  2682. Returns the new surface, or NULL if there was an error.
  2683. The new surface should be freed with SDL_FreeSurface(). }
  2684. function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface;
  2685. cdecl; external {$IFDEF __GPC__}name 'SDL_LoadBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2686. {$EXTERNALSYM SDL_LoadBMP_RW}
  2687. // Convenience macro -- load a surface from a file
  2688. function SDL_LoadBMP(filename: PChar): PSDL_Surface;
  2689. {$EXTERNALSYM SDL_LoadBMP}
  2690. { Save a surface to a seekable SDL data source (memory or file.)
  2691. If 'freedst' is non-zero, the source will be closed after being written.
  2692. Returns 0 if successful or -1 if there was an error. }
  2693. function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: Integer): Integer;
  2694. cdecl; external {$IFDEF __GPC__}name 'SDL_SaveBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2695. {$EXTERNALSYM SDL_SaveBMP_RW}
  2696. // Convenience macro -- save a surface to a file
  2697. function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer;
  2698. {$EXTERNALSYM SDL_SaveBMP}
  2699. { Sets the color key (transparent pixel) in a blittable surface.
  2700. If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
  2701. 'key' will be the transparent pixel in the source image of a blit.
  2702. SDL_RLEACCEL requests RLE acceleration for the surface if present,
  2703. and removes RLE acceleration if absent.
  2704. If 'flag' is 0, this function clears any current color key.
  2705. This function returns 0, or -1 if there was an error. }
  2706. function SDL_SetColorKey(surface: PSDL_Surface; flag, key: UInt32) : Integer;
  2707. cdecl; external {$IFDEF __GPC__}name 'SDL_SetColorKey'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2708. {$EXTERNALSYM SDL_SetColorKey}
  2709. { This function sets the alpha value for the entire surface, as opposed to
  2710. using the alpha component of each pixel. This value measures the range
  2711. of transparency of the surface, 0 being completely transparent to 255
  2712. being completely opaque. An 'alpha' value of 255 causes blits to be
  2713. opaque, the source pixels copied to the destination (the default). Note
  2714. that per-surface alpha can be combined with colorkey transparency.
  2715. If 'flag' is 0, alpha blending is disabled for the surface.
  2716. If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
  2717. OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
  2718. surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. }
  2719. function SDL_SetAlpha(surface: PSDL_Surface; flag: UInt32; alpha: UInt8): Integer;
  2720. cdecl; external {$IFDEF __GPC__}name 'SDL_SetAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2721. {$EXTERNALSYM SDL_SetAlpha}
  2722. { Sets the clipping rectangle for the destination surface in a blit.
  2723. If the clip rectangle is NULL, clipping will be disabled.
  2724. If the clip rectangle doesn't intersect the surface, the function will
  2725. return SDL_FALSE and blits will be completely clipped. Otherwise the
  2726. function returns SDL_TRUE and blits to the surface will be clipped to
  2727. the intersection of the surface area and the clipping rectangle.
  2728. Note that blits are automatically clipped to the edges of the source
  2729. and destination surfaces. }
  2730. procedure SDL_SetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl;
  2731. external {$IFDEF __GPC__}name 'SDL_SetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2732. {$EXTERNALSYM SDL_SetClipRect}
  2733. { Gets the clipping rectangle for the destination surface in a blit.
  2734. 'rect' must be a pointer to a valid rectangle which will be filled
  2735. with the correct values. }
  2736. procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl;
  2737. external {$IFDEF __GPC__}name 'SDL_GetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2738. {$EXTERNALSYM SDL_GetClipRect}
  2739. { Creates a new surface of the specified format, and then copies and maps
  2740. the given surface to it so the blit of the converted surface will be as
  2741. fast as possible. If this function fails, it returns NULL.
  2742. The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
  2743. semantics. You can also pass SDL_RLEACCEL in the flags parameter and
  2744. SDL will try to RLE accelerate colorkey and alpha blits in the resulting
  2745. surface.
  2746. This function is used internally by SDL_DisplayFormat(). }
  2747. function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface;
  2748. cdecl; external {$IFDEF __GPC__}name 'SDL_ConvertSurface'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2749. {$EXTERNALSYM SDL_ConvertSurface}
  2750. {
  2751. This performs a fast blit from the source surface to the destination
  2752. surface. It assumes that the source and destination rectangles are
  2753. the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
  2754. surface (src or dst) is copied. The final blit rectangles are saved
  2755. in 'srcrect' and 'dstrect' after all clipping is performed.
  2756. If the blit is successful, it returns 0, otherwise it returns -1.
  2757. The blit function should not be called on a locked surface.
  2758. The blit semantics for surfaces with and without alpha and colorkey
  2759. are defined as follows:
  2760. RGBA->RGB:
  2761. SDL_SRCALPHA set:
  2762. alpha-blend (using alpha-channel).
  2763. SDL_SRCCOLORKEY ignored.
  2764. SDL_SRCALPHA not set:
  2765. copy RGB.
  2766. if SDL_SRCCOLORKEY set, only copy the pixels matching the
  2767. RGB values of the source colour key, ignoring alpha in the
  2768. comparison.
  2769. RGB->RGBA:
  2770. SDL_SRCALPHA set:
  2771. alpha-blend (using the source per-surface alpha value);
  2772. set destination alpha to opaque.
  2773. SDL_SRCALPHA not set:
  2774. copy RGB, set destination alpha to opaque.
  2775. both:
  2776. if SDL_SRCCOLORKEY set, only copy the pixels matching the
  2777. source colour key.
  2778. RGBA->RGBA:
  2779. SDL_SRCALPHA set:
  2780. alpha-blend (using the source alpha channel) the RGB values;
  2781. leave destination alpha untouched. [Note: is this correct?]
  2782. SDL_SRCCOLORKEY ignored.
  2783. SDL_SRCALPHA not set:
  2784. copy all of RGBA to the destination.
  2785. if SDL_SRCCOLORKEY set, only copy the pixels matching the
  2786. RGB values of the source colour key, ignoring alpha in the
  2787. comparison.
  2788. RGB->RGB:
  2789. SDL_SRCALPHA set:
  2790. alpha-blend (using the source per-surface alpha value).
  2791. SDL_SRCALPHA not set:
  2792. copy RGB.
  2793. both:
  2794. if SDL_SRCCOLORKEY set, only copy the pixels matching the
  2795. source colour key.
  2796. If either of the surfaces were in video memory, and the blit returns -2,
  2797. the video memory was lost, so it should be reloaded with artwork and
  2798. re-blitted:
  2799. while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do
  2800. begin
  2801. while ( SDL_LockSurface(image) < 0 ) do
  2802. Sleep(10);
  2803. -- Write image pixels to image->pixels --
  2804. SDL_UnlockSurface(image);
  2805. end;
  2806. This happens under DirectX 5.0 when the system switches away from your
  2807. fullscreen application. The lock will also fail until you have access
  2808. to the video memory again. }
  2809. { You should call SDL_BlitSurface() unless you know exactly how SDL
  2810. blitting works internally and how to use the other blit functions. }
  2811. function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
  2812. {$EXTERNALSYM SDL_BlitSurface}
  2813. { This is the public blit function, SDL_BlitSurface(), and it performs
  2814. rectangle validation and clipping before passing it to SDL_LowerBlit() }
  2815. function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
  2816. cdecl; external {$IFDEF __GPC__}name 'SDL_UpperBlit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2817. {$EXTERNALSYM SDL_UpperBlit}
  2818. { This is a semi-private blit function and it performs low-level surface
  2819. blitting only. }
  2820. function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
  2821. cdecl; external {$IFDEF __GPC__}name 'SDL_LowerBlit'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2822. {$EXTERNALSYM SDL_LowerBlit}
  2823. { This function performs a fast fill of the given rectangle with 'color'
  2824. The given rectangle is clipped to the destination surface clip area
  2825. and the final fill rectangle is saved in the passed in pointer.
  2826. If 'dstrect' is NULL, the whole surface will be filled with 'color'
  2827. The color should be a pixel of the format used by the surface, and
  2828. can be generated by the SDL_MapRGB() function.
  2829. This function returns 0 on success, or -1 on error. }
  2830. function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: UInt32) : Integer;
  2831. cdecl; external {$IFDEF __GPC__}name 'SDL_FillRect'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2832. {$EXTERNALSYM SDL_FillRect}
  2833. { This function takes a surface and copies it to a new surface of the
  2834. pixel format and colors of the video framebuffer, suitable for fast
  2835. blitting onto the display surface. It calls SDL_ConvertSurface()
  2836. If you want to take advantage of hardware colorkey or alpha blit
  2837. acceleration, you should set the colorkey and alpha value before
  2838. calling this function.
  2839. If the conversion fails or runs out of memory, it returns NULL }
  2840. function SDL_DisplayFormat(surface: PSDL_Surface): PSDL_Surface; cdecl;
  2841. external {$IFDEF __GPC__}name 'SDL_DisplayFormat'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2842. {$EXTERNALSYM SDL_DisplayFormat}
  2843. { This function takes a surface and copies it to a new surface of the
  2844. pixel format and colors of the video framebuffer (if possible),
  2845. suitable for fast alpha blitting onto the display surface.
  2846. The new surface will always have an alpha channel.
  2847. If you want to take advantage of hardware colorkey or alpha blit
  2848. acceleration, you should set the colorkey and alpha value before
  2849. calling this function.
  2850. If the conversion fails or runs out of memory, it returns NULL }
  2851. function SDL_DisplayFormatAlpha(surface: PSDL_Surface): PSDL_Surface; cdecl;
  2852. external {$IFDEF __GPC__}name 'SDL_DisplayFormatAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2853. {$EXTERNALSYM SDL_DisplayFormatAlpha}
  2854. //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2855. //* YUV video surface overlay functions */
  2856. //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2857. { This function creates a video output overlay
  2858. Calling the returned surface an overlay is something of a misnomer because
  2859. the contents of the display surface underneath the area where the overlay
  2860. is shown is undefined - it may be overwritten with the converted YUV data. }
  2861. function SDL_CreateYUVOverlay(width: Integer; height: Integer; format: UInt32; display: PSDL_Surface): PSDL_Overlay;
  2862. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2863. {$EXTERNALSYM SDL_CreateYUVOverlay}
  2864. // Lock an overlay for direct access, and unlock it when you are done
  2865. function SDL_LockYUVOverlay(Overlay: PSDL_Overlay): Integer;
  2866. cdecl; external {$IFDEF __GPC__}name 'SDL_LockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2867. {$EXTERNALSYM SDL_LockYUVOverlay}
  2868. procedure SDL_UnlockYUVOverlay(Overlay: PSDL_Overlay); cdecl;
  2869. external {$IFDEF __GPC__}name 'SDL_UnlockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2870. {$EXTERNALSYM SDL_UnlockYUVOverlay}
  2871. { Blit a video overlay to the display surface.
  2872. The contents of the video surface underneath the blit destination are
  2873. not defined.
  2874. The width and height of the destination rectangle may be different from
  2875. that of the overlay, but currently only 2x scaling is supported. }
  2876. function SDL_DisplayYUVOverlay(Overlay: PSDL_Overlay; dstrect: PSDL_Rect) : Integer;
  2877. cdecl; external {$IFDEF __GPC__}name 'SDL_DisplayYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2878. {$EXTERNALSYM SDL_DisplayYUVOverlay}
  2879. // Free a video overlay
  2880. procedure SDL_FreeYUVOverlay(Overlay: PSDL_Overlay);
  2881. cdecl; external {$IFDEF __GPC__}name 'SDL_FreeYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2882. {$EXTERNALSYM SDL_FreeYUVOverlay}
  2883. {------------------------------------------------------------------------------}
  2884. { OpenGL Routines }
  2885. {------------------------------------------------------------------------------}
  2886. { Dynamically load a GL driver, if SDL is built with dynamic GL.
  2887. SDL links normally with the OpenGL library on your system by default,
  2888. but you can compile it to dynamically load the GL driver at runtime.
  2889. If you do this, you need to retrieve all of the GL functions used in
  2890. your program from the dynamic library using SDL_GL_GetProcAddress().
  2891. This is disabled in default builds of SDL. }
  2892. function SDL_GL_LoadLibrary(filename: PChar): Integer;
  2893. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_LoadLibrary'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2894. {$EXTERNALSYM SDL_GL_LoadLibrary}
  2895. { Get the address of a GL function (for extension functions) }
  2896. function SDL_GL_GetProcAddress(procname: PChar) : Pointer;
  2897. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_GetProcAddress'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2898. {$EXTERNALSYM SDL_GL_GetProcAddress}
  2899. { Set an attribute of the OpenGL subsystem before intialization. }
  2900. function SDL_GL_SetAttribute(attr: TSDL_GLAttr; value: Integer) : Integer;
  2901. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_SetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2902. {$EXTERNALSYM SDL_GL_SetAttribute}
  2903. { Get an attribute of the OpenGL subsystem from the windowing
  2904. interface, such as glX. This is of course different from getting
  2905. the values from SDL's internal OpenGL subsystem, which only
  2906. stores the values you request before initialization.
  2907. Developers should track the values they pass into SDL_GL_SetAttribute
  2908. themselves if they want to retrieve these values. }
  2909. function SDL_GL_GetAttribute(attr: TSDL_GLAttr; var value: Integer): Integer;
  2910. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_GetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2911. {$EXTERNALSYM SDL_GL_GetAttribute}
  2912. { Swap the OpenGL buffers, if double-buffering is supported. }
  2913. procedure SDL_GL_SwapBuffers;
  2914. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_SwapBuffers'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2915. {$EXTERNALSYM SDL_GL_SwapBuffers;}
  2916. { Internal functions that should not be called unless you have read
  2917. and understood the source code for these functions. }
  2918. procedure SDL_GL_UpdateRects(numrects: Integer; rects: PSDL_Rect);
  2919. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2920. {$EXTERNALSYM SDL_GL_UpdateRects}
  2921. procedure SDL_GL_Lock;
  2922. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_Lock'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2923. {$EXTERNALSYM SDL_GL_Lock;}
  2924. procedure SDL_GL_Unlock;
  2925. cdecl; external {$IFDEF __GPC__}name 'SDL_GL_Unlock'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2926. {$EXTERNALSYM SDL_GL_Unlock;}
  2927. {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  2928. {* These functions allow interaction with the window manager, if any. *}
  2929. {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  2930. { Sets/Gets the title and icon text of the display window }
  2931. procedure SDL_WM_GetCaption(var title : PChar; var icon : PChar);
  2932. cdecl; external {$IFDEF __GPC__}name 'SDL_WM_GetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2933. {$EXTERNALSYM SDL_WM_GetCaption}
  2934. procedure SDL_WM_SetCaption( const title : PChar; const icon : PChar);
  2935. cdecl; external {$IFDEF __GPC__}name 'SDL_WM_SetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2936. {$EXTERNALSYM SDL_WM_SetCaption}
  2937. { Sets the icon for the display window.
  2938. This function must be called before the first call to SDL_SetVideoMode().
  2939. It takes an icon surface, and a mask in MSB format.
  2940. If 'mask' is NULL, the entire icon surface will be used as the icon. }
  2941. procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask: UInt8);
  2942. cdecl; external {$IFDEF __GPC__}name 'SDL_WM_SetIcon'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2943. {$EXTERNALSYM SDL_WM_SetIcon}
  2944. { This function iconifies the window, and returns 1 if it succeeded.
  2945. If the function succeeds, it generates an SDL_APPACTIVE loss event.
  2946. This function is a noop and returns 0 in non-windowed environments. }
  2947. function SDL_WM_IconifyWindow: Integer;
  2948. cdecl; external {$IFDEF __GPC__}name 'SDL_WM_IconifyWindow'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2949. {$EXTERNALSYM SDL_WM_IconifyWindow}
  2950. { Toggle fullscreen mode without changing the contents of the screen.
  2951. If the display surface does not require locking before accessing
  2952. the pixel information, then the memory pointers will not change.
  2953. If this function was able to toggle fullscreen mode (change from
  2954. running in a window to fullscreen, or vice-versa), it will return 1.
  2955. If it is not implemented, or fails, it returns 0.
  2956. The next call to SDL_SetVideoMode() will set the mode fullscreen
  2957. attribute based on the flags parameter - if SDL_FULLSCREEN is not
  2958. set, then the display will be windowed by default where supported.
  2959. This is currently only implemented in the X11 video driver. }
  2960. function SDL_WM_ToggleFullScreen(surface: PSDL_Surface): Integer;
  2961. cdecl; external {$IFDEF __GPC__}name 'SDL_WM_ToggleFullScreen'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2962. {$EXTERNALSYM SDL_WM_ToggleFullScreen}
  2963. { Grabbing means that the mouse is confined to the application window,
  2964. and nearly all keyboard input is passed directly to the application,
  2965. and not interpreted by a window manager, if any. }
  2966. function SDL_WM_GrabInput(mode: TSDL_GrabMode): TSDL_GrabMode;
  2967. cdecl; external {$IFDEF __GPC__}name 'SDL_WM_GrabInput'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2968. {$EXTERNALSYM SDL_WM_GrabInput}
  2969. {------------------------------------------------------------------------------}
  2970. { mouse-routines }
  2971. {------------------------------------------------------------------------------}
  2972. { Retrieve the current state of the mouse.
  2973. The current button state is returned as a button bitmask, which can
  2974. be tested using the SDL_BUTTON(X) macros, and x and y are set to the
  2975. current mouse cursor position. You can pass NULL for either x or y. }
  2976. function SDL_GetMouseState(var x: Integer; var y: Integer): UInt8;
  2977. cdecl; external {$IFDEF __GPC__}name 'SDL_GetMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2978. {$EXTERNALSYM SDL_GetMouseState}
  2979. { Retrieve the current state of the mouse.
  2980. The current button state is returned as a button bitmask, which can
  2981. be tested using the SDL_BUTTON(X) macros, and x and y are set to the
  2982. mouse deltas since the last call to SDL_GetRelativeMouseState(). }
  2983. function SDL_GetRelativeMouseState(var x: Integer; var y: Integer): UInt8;
  2984. cdecl; external {$IFDEF __GPC__}name 'SDL_GetRelativeMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2985. {$EXTERNALSYM SDL_GetRelativeMouseState}
  2986. { Set the position of the mouse cursor (generates a mouse motion event) }
  2987. procedure SDL_WarpMouse(x, y: UInt16);
  2988. cdecl; external {$IFDEF __GPC__}name 'SDL_WarpMouse'{$ELSE} SDLLibName{$ENDIF __GPC__};
  2989. {$EXTERNALSYM SDL_WarpMouse}
  2990. { Create a cursor using the specified data and mask (in MSB format).
  2991. The cursor width must be a multiple of 8 bits.
  2992. The cursor is created in black and white according to the following:
  2993. data mask resulting pixel on screen
  2994. 0 1 White
  2995. 1 1 Black
  2996. 0 0 Transparent
  2997. 1 0 Inverted color if possible, black if not.
  2998. Cursors created with this function must be freed with SDL_FreeCursor(). }
  2999. function SDL_CreateCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer): PSDL_Cursor;
  3000. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateCursor'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3001. {$EXTERNALSYM SDL_CreateCursor}
  3002. { Set the currently active cursor to the specified one.
  3003. If the cursor is currently visible, the change will be immediately
  3004. represented on the display. }
  3005. procedure SDL_SetCursor(cursor: PSDL_Cursor);
  3006. cdecl; external {$IFDEF __GPC__}name 'SDL_SetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3007. {$EXTERNALSYM SDL_SetCursor}
  3008. { Returns the currently active cursor. }
  3009. function SDL_GetCursor: PSDL_Cursor;
  3010. cdecl; external {$IFDEF __GPC__}name 'SDL_GetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3011. {$EXTERNALSYM SDL_GetCursor}
  3012. { Deallocates a cursor created with SDL_CreateCursor(). }
  3013. procedure SDL_FreeCursor(cursor: PSDL_Cursor);
  3014. cdecl; external {$IFDEF __GPC__}name 'SDL_FreeCursor'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3015. {$EXTERNALSYM SDL_FreeCursor}
  3016. { Toggle whether or not the cursor is shown on the screen.
  3017. The cursor start off displayed, but can be turned off.
  3018. SDL_ShowCursor() returns 1 if the cursor was being displayed
  3019. before the call, or 0 if it was not. You can query the current
  3020. state by passing a 'toggle' value of -1. }
  3021. function SDL_ShowCursor(toggle: Integer): Integer;
  3022. cdecl; external {$IFDEF __GPC__}name 'SDL_ShowCursor'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3023. {$EXTERNALSYM SDL_ShowCursor}
  3024. function SDL_BUTTON( Button : Integer ) : Integer;
  3025. {------------------------------------------------------------------------------}
  3026. { Keyboard-routines }
  3027. {------------------------------------------------------------------------------}
  3028. { Enable/Disable UNICODE translation of keyboard input.
  3029. This translation has some overhead, so translation defaults off.
  3030. If 'enable' is 1, translation is enabled.
  3031. If 'enable' is 0, translation is disabled.
  3032. If 'enable' is -1, the translation state is not changed.
  3033. It returns the previous state of keyboard translation. }
  3034. function SDL_EnableUNICODE(enable: Integer): Integer;
  3035. cdecl; external {$IFDEF __GPC__}name 'SDL_EnableUNICODE'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3036. {$EXTERNALSYM SDL_EnableUNICODE}
  3037. { If 'delay' is set to 0, keyboard repeat is disabled. }
  3038. function SDL_EnableKeyRepeat(delay: Integer; interval: Integer): Integer;
  3039. cdecl; external {$IFDEF __GPC__}name 'SDL_EnableKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3040. {$EXTERNALSYM SDL_EnableKeyRepeat}
  3041. { Get a snapshot of the current state of the keyboard.
  3042. Returns an array of keystates, indexed by the SDLK_* syms.
  3043. Used:
  3044. UInt8 *keystate = SDL_GetKeyState(NULL);
  3045. if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed }
  3046. function SDL_GetKeyState(numkeys: PInt): PUInt8;
  3047. cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3048. {$EXTERNALSYM SDL_GetKeyState}
  3049. { Get the current key modifier state }
  3050. function SDL_GetModState: TSDLMod;
  3051. cdecl; external {$IFDEF __GPC__}name 'SDL_GetModState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3052. {$EXTERNALSYM SDL_GetModState}
  3053. { Set the current key modifier state
  3054. This does not change the keyboard state, only the key modifier flags. }
  3055. procedure SDL_SetModState(modstate: TSDLMod);
  3056. cdecl; external {$IFDEF __GPC__}name 'SDL_SetModState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3057. {$EXTERNALSYM SDL_SetModState}
  3058. { Get the name of an SDL virtual keysym }
  3059. function SDL_GetKeyName(key: TSDLKey): PChar;
  3060. cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyName'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3061. {$EXTERNALSYM SDL_GetKeyName}
  3062. {------------------------------------------------------------------------------}
  3063. { Active Routines }
  3064. {------------------------------------------------------------------------------}
  3065. { This function returns the current state of the application, which is a
  3066. bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
  3067. SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to
  3068. see your application, otherwise it has been iconified or disabled. }
  3069. function SDL_GetAppState: UInt8;
  3070. cdecl; external {$IFDEF __GPC__}name 'SDL_GetAppState'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3071. {$EXTERNALSYM SDL_GetAppState}
  3072. { Mutex functions }
  3073. { Create a mutex, initialized unlocked }
  3074. function SDL_CreateMutex: PSDL_Mutex;
  3075. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateMutex'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3076. {$EXTERNALSYM SDL_CreateMutex}
  3077. { Lock the mutex (Returns 0, or -1 on error) }
  3078. function SDL_mutexP(mutex: PSDL_mutex): Integer;
  3079. cdecl; external {$IFDEF __GPC__}name 'SDL_mutexP'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3080. { $ EXTERNALSYM SDL_mutexP}
  3081. function SDL_LockMutex(mutex: PSDL_mutex): Integer;
  3082. {$EXTERNALSYM SDL_LockMutex}
  3083. { Unlock the mutex (Returns 0, or -1 on error) }
  3084. function SDL_mutexV(mutex: PSDL_mutex): Integer;
  3085. cdecl; external {$IFDEF __GPC__}name 'SDL_mutexV'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3086. {$EXTERNALSYM SDL_mutexV}
  3087. function SDL_UnlockMutex(mutex: PSDL_mutex): Integer;
  3088. {$EXTERNALSYM SDL_UnlockMutex}
  3089. { Destroy a mutex }
  3090. procedure SDL_DestroyMutex(mutex: PSDL_mutex);
  3091. cdecl; external {$IFDEF __GPC__}name 'SDL_DestroyMutex'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3092. {$EXTERNALSYM SDL_DestroyMutex}
  3093. { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
  3094. { Semaphore functions }
  3095. { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
  3096. { Create a semaphore, initialized with value, returns NULL on failure. }
  3097. function SDL_CreateSemaphore(initial_value: UInt32): PSDL_Sem;
  3098. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateSemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3099. {$EXTERNALSYM SDL_CreateSemaphore}
  3100. { Destroy a semaphore }
  3101. procedure SDL_DestroySemaphore(sem: PSDL_sem);
  3102. cdecl; external {$IFDEF __GPC__}name 'SDL_DestroySemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3103. {$EXTERNALSYM SDL_DestroySemaphore}
  3104. { This function suspends the calling thread until the semaphore pointed
  3105. to by sem has a positive count. It then atomically decreases the semaphore
  3106. count. }
  3107. function SDL_SemWait(sem: PSDL_sem): Integer;
  3108. cdecl; external {$IFDEF __GPC__}name 'SDL_SemWait'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3109. {$EXTERNALSYM SDL_SemWait}
  3110. { Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
  3111. SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. }
  3112. function SDL_SemTryWait(sem: PSDL_sem): Integer;
  3113. cdecl; external {$IFDEF __GPC__}name 'SDL_SemTryWait'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3114. {$EXTERNALSYM SDL_SemTryWait}
  3115. { Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
  3116. the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
  3117. the allotted time, and -1 on error.
  3118. On some platforms this function is implemented by looping with a delay
  3119. of 1 ms, and so should be avoided if possible. }
  3120. function SDL_SemWaitTimeout(sem: PSDL_sem; ms: UInt32): Integer;
  3121. cdecl; external {$IFDEF __GPC__}name 'SDL_SemWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3122. {$EXTERNALSYM SDL_SemTryWait}
  3123. { Atomically increases the semaphore's count (not blocking), returns 0,
  3124. or -1 on error. }
  3125. function SDL_SemPost(sem: PSDL_sem): Integer;
  3126. cdecl; external {$IFDEF __GPC__}name 'SDL_SemPost'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3127. {$EXTERNALSYM SDL_SemTryWait}
  3128. { Returns the current count of the semaphore }
  3129. function SDL_SemValue(sem: PSDL_sem): UInt32;
  3130. cdecl; external {$IFDEF __GPC__}name 'SDL_SemValue'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3131. {$EXTERNALSYM SDL_SemValue}
  3132. { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
  3133. { Condition variable functions }
  3134. { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
  3135. { Create a condition variable }
  3136. function SDL_CreateCond: PSDL_Cond;
  3137. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateCond'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3138. {$EXTERNALSYM SDL_CreateCond}
  3139. { Destroy a condition variable }
  3140. procedure SDL_DestroyCond(cond: PSDL_Cond);
  3141. cdecl; external {$IFDEF __GPC__}name 'SDL_DestroyCond'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3142. {$EXTERNALSYM SDL_DestroyCond}
  3143. { Restart one of the threads that are waiting on the condition variable,
  3144. returns 0 or -1 on error. }
  3145. function SDL_CondSignal(cond: PSDL_cond): Integer;
  3146. cdecl; external {$IFDEF __GPC__}name 'SDL_CondSignal'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3147. {$EXTERNALSYM SDL_CondSignal}
  3148. { Restart all threads that are waiting on the condition variable,
  3149. returns 0 or -1 on error. }
  3150. function SDL_CondBroadcast(cond: PSDL_cond): Integer;
  3151. cdecl; external {$IFDEF __GPC__}name 'SDL_CondBroadcast'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3152. {$EXTERNALSYM SDL_CondBroadcast}
  3153. { Wait on the condition variable, unlocking the provided mutex.
  3154. The mutex must be locked before entering this function!
  3155. Returns 0 when it is signaled, or -1 on error. }
  3156. function SDL_CondWait(cond: PSDL_cond; mut: PSDL_mutex): Integer;
  3157. cdecl; external {$IFDEF __GPC__}name 'SDL_CondWait'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3158. {$EXTERNALSYM SDL_CondWait}
  3159. { Waits for at most 'ms' milliseconds, and returns 0 if the condition
  3160. variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
  3161. signaled in the allotted time, and -1 on error.
  3162. On some platforms this function is implemented by looping with a delay
  3163. of 1 ms, and so should be avoided if possible. }
  3164. function SDL_CondWaitTimeout(cond: PSDL_cond; mut: PSDL_mutex; ms: UInt32) : Integer;
  3165. cdecl; external {$IFDEF __GPC__}name 'SDL_CondWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3166. {$EXTERNALSYM SDL_CondWaitTimeout}
  3167. { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
  3168. { Condition variable functions }
  3169. { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
  3170. { Create a thread }
  3171. function SDL_CreateThread(fn: PInt; data: Pointer): PSDL_Thread;
  3172. cdecl; external {$IFDEF __GPC__}name 'SDL_CreateThread'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3173. {$EXTERNALSYM SDL_CreateThread}
  3174. { Get the 32-bit thread identifier for the current thread }
  3175. function SDL_ThreadID: UInt32;
  3176. cdecl; external {$IFDEF __GPC__}name 'SDL_ThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3177. {$EXTERNALSYM SDL_ThreadID}
  3178. { Get the 32-bit thread identifier for the specified thread,
  3179. equivalent to SDL_ThreadID() if the specified thread is NULL. }
  3180. function SDL_GetThreadID(thread: PSDL_Thread): UInt32;
  3181. cdecl; external {$IFDEF __GPC__}name 'SDL_GetThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3182. {$EXTERNALSYM SDL_GetThreadID}
  3183. { Wait for a thread to finish.
  3184. The return code for the thread function is placed in the area
  3185. pointed to by 'status', if 'status' is not NULL. }
  3186. procedure SDL_WaitThread(thread: PSDL_Thread; var status: Integer);
  3187. cdecl; external {$IFDEF __GPC__}name 'SDL_WaitThread'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3188. {$EXTERNALSYM SDL_WaitThread}
  3189. { Forcefully kill a thread without worrying about its state }
  3190. procedure SDL_KillThread(thread: PSDL_Thread);
  3191. cdecl; external {$IFDEF __GPC__}name 'SDL_KillThread'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3192. {$EXTERNALSYM SDL_KillThread}
  3193. {------------------------------------------------------------------------------}
  3194. { Get Environment Routines }
  3195. {------------------------------------------------------------------------------}
  3196. {$IFDEF WIN32}
  3197. function _putenv( const variable : Pchar ): integer;
  3198. cdecl;
  3199. {$ENDIF}
  3200. {$IFDEF Unix}
  3201. {$IFDEF FPC}
  3202. function _putenv( const variable : Pchar ): integer;
  3203. cdecl; external 'libc.so' name 'putenv';
  3204. {$ENDIF}
  3205. {$ENDIF}
  3206. { Put a variable of the form "name=value" into the environment }
  3207. //function SDL_putenv(const variable: PChar): integer; cdecl; external {$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name '';
  3208. function SDL_putenv(const variable: PChar): integer;
  3209. {$EXTERNALSYM SDL_putenv}
  3210. // The following function has been commented out to encourage developers to use
  3211. // SDL_putenv as it it more portable
  3212. //function putenv(const variable: PChar): integer;
  3213. //{$EXTERNALSYM putenv}
  3214. {$IFDEF WIN32}
  3215. {$IFNDEF __GPC__}
  3216. function getenv( const name : Pchar ): PChar; cdecl;
  3217. {$ENDIF}
  3218. {$ENDIF}
  3219. {* Retrieve a variable named "name" from the environment }
  3220. //function SDL_getenv(const name: PChar): PChar; cdecl; external {$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name '';
  3221. function SDL_getenv(const name: PChar): PChar;
  3222. {$EXTERNALSYM SDL_getenv}
  3223. // The following function has been commented out to encourage developers to use
  3224. // SDL_getenv as it it more portable
  3225. //function getenv(const name: PChar): PChar;
  3226. //{$EXTERNALSYM getenv}
  3227. {*
  3228. * This function gives you custom hooks into the window manager information.
  3229. * It fills the structure pointed to by 'info' with custom information and
  3230. * returns 1 if the function is implemented. If it's not implemented, or
  3231. * the version member of the 'info' structure is invalid, it returns 0.
  3232. *}
  3233. function SDL_GetWMInfo(info : PSDL_SysWMinfo) : integer;
  3234. cdecl; external {$IFDEF __GPC__}name 'SDL_GetWMInfo'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3235. {$EXTERNALSYM SDL_GetWMInfo}
  3236. {------------------------------------------------------------------------------}
  3237. //SDL_loadso.h
  3238. {* This function dynamically loads a shared object and returns a pointer
  3239. * to the object handle (or NULL if there was an error).
  3240. * The 'sofile' parameter is a system dependent name of the object file.
  3241. *}
  3242. function SDL_LoadObject( const sofile : PChar ) : Pointer;
  3243. cdecl; external {$IFDEF __GPC__}name 'SDL_LoadObject'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3244. {$EXTERNALSYM SDL_LoadObject}
  3245. {* Given an object handle, this function looks up the address of the
  3246. * named function in the shared object and returns it. This address
  3247. * is no longer valid after calling SDL_UnloadObject().
  3248. *}
  3249. function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
  3250. cdecl; external {$IFDEF __GPC__}name 'SDL_LoadFunction'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3251. {$EXTERNALSYM SDL_LoadFunction}
  3252. {* Unload a shared object from memory *}
  3253. procedure SDL_UnloadObject( handle : Pointer );
  3254. cdecl; external {$IFDEF __GPC__}name 'SDL_UnloadObject'{$ELSE} SDLLibName{$ENDIF __GPC__};
  3255. {$EXTERNALSYM SDL_UnloadObject}
  3256. {------------------------------------------------------------------------------}
  3257. function SDL_Swap32(D: Uint32): Uint32;
  3258. {$EXTERNALSYM SDL_Swap32}
  3259. { FreeAndNil frees the given TObject instance and sets the variable reference
  3260. to nil. Be careful to only pass TObjects to this routine. }
  3261. procedure FreeAndNil(var Obj);
  3262. { Exit procedure handling }
  3263. { AddExitProc adds the given procedure to the run-time library's exit
  3264. procedure list. When an application terminates, its exit procedures are
  3265. executed in reverse order of definition, i.e. the last procedure passed
  3266. to AddExitProc is the first one to get executed upon termination. }
  3267. procedure AddExitProc(Proc: TProcedure);
  3268. // Bitwise Checking functions
  3269. function IsBitOn( value : integer; bit : Byte ) : boolean;
  3270. function TurnBitOn( value : integer; bit : Byte ) : integer;
  3271. function TurnBitOff( value : integer; bit : Byte ) : integer;
  3272. implementation
  3273. {$IFDEF __GPC__}
  3274. {$L 'sdl'} { link sdl.dll.a or libsdl.so or libsdl.a }
  3275. {$ENDIF}
  3276. function SDL_TABLESIZE(table: PChar): Integer;
  3277. begin
  3278. Result := SizeOf(table) div SizeOf(table[0]);
  3279. end;
  3280. procedure SDL_OutOfMemory;
  3281. begin
  3282. {$IFNDEF WIN32}
  3283. SDL_Error(SDL_ENOMEM);
  3284. {$ENDIF}
  3285. end;
  3286. function SDL_GetPixel(Surface: PSDL_Surface; const x, y: integer): SInt32;{$ifdef fpc} inline; {$endif}
  3287. var bits: PByte;
  3288. Bpp: UInt32;
  3289. r, g, b: byte;
  3290. begin
  3291. assert(x>=0);
  3292. assert(x<Surface^.w);
  3293. SDL_GetPixel:=-1;
  3294. Bpp:=Surface^.Format^.BytesPerPixel;
  3295. bits:=PByte(Surface^.Pixels) + Word(Y) * Word(Surface^.Pitch) + Word(X) * Bpp;
  3296. case Bpp of
  3297. 1: SDL_GetPixel:=(PByte(Surface^.Pixels) + Y * Surface^.Pitch + X)^;
  3298. 2: SDL_GetPixel:=(PWord(Surface^.Pixels) + Y * Surface^.Pitch div 2 + X)^;
  3299. 3: begin
  3300. r:=(bits + Surface^.Format^.RShift div 8)^;
  3301. g:=(bits + Surface^.Format^.GShift div 8)^;
  3302. b:=(bits + Surface^.Format^.BShift div 8)^;
  3303. SDL_GetPixel:=SDL_MapRGB(Surface^.Format, r, g, b);
  3304. end;
  3305. 4: SDL_GetPixel:=(PCardinal(Surface^.Pixels) + Y * Surface^.Pitch div 4 + X)^;
  3306. end;
  3307. end;
  3308. procedure SDL_PutPixel(Surface: PSDL_Surface; const x, y: integer; pixel: UInt32); {$ifdef fpc} inline; {$endif}
  3309. var bits: PByte;
  3310. Bpp: UInt32;
  3311. r, g, b: byte;
  3312. begin
  3313. assert(x>=0);
  3314. assert(x<Surface^.w);
  3315. Bpp:=Surface^.Format^.BytesPerPixel;
  3316. bits:=PByte(Surface^.Pixels) + Word(Y) * Word(Surface^.Pitch) + Word(X) * Bpp;
  3317. case Bpp of
  3318. 1: PUInt32(PByte(Surface^.Pixels) + Y * Surface^.Pitch + X)^:=Pixel;
  3319. 2: PUint32(PWord(Surface^.Pixels) + Y * Surface^.Pitch div 2 + X)^:=Pixel;
  3320. 3: begin
  3321. SDL_GetRGB(pixel, Surface^.Format, @r, @g, @b);
  3322. (bits + Surface^.Format^.RShift div 8)^:=r;
  3323. (bits + Surface^.Format^.GShift div 8)^:=g;
  3324. (bits + Surface^.Format^.BShift div 8)^:=b;
  3325. end;
  3326. 4: (PCardinal(Surface^.Pixels) + Y * Surface^.Pitch div 4 + X)^:=Pixel;
  3327. end;
  3328. end;
  3329. function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer;
  3330. begin
  3331. Result := context^.seek(context, offset, whence);
  3332. end;
  3333. function SDL_RWTell(context: PSDL_RWops): Integer;
  3334. begin
  3335. Result := context^.seek(context, 0, 1);
  3336. end;
  3337. function SDL_RWRead(context: PSDL_RWops; ptr: Pointer; size: Integer; n: Integer): Integer;
  3338. begin
  3339. Result := context^.read(context, ptr, size, n);
  3340. end;
  3341. function SDL_RWWrite(context: PSDL_RWops; ptr: Pointer; size: Integer; n: Integer): Integer;
  3342. begin
  3343. Result := context^.write(context, ptr, size, n);
  3344. end;
  3345. function SDL_RWClose(context: PSDL_RWops): Integer;
  3346. begin
  3347. Result := context^.close(context);
  3348. end;
  3349. function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
  3350. begin
  3351. Result := SDL_LoadWAV_RW(SDL_RWFromFile(filename, 'rb'), 1, spec, audio_buf, audiolen);
  3352. end;
  3353. function SDL_CDInDrive( status : TSDL_CDStatus ): LongBool;
  3354. begin
  3355. Result := ord( status ) > ord( CD_ERROR );
  3356. end;
  3357. procedure FRAMES_TO_MSF(frames: Integer; var M: Integer; var S: Integer; var
  3358. F: Integer);
  3359. var
  3360. value: Integer;
  3361. begin
  3362. value := frames;
  3363. F := value mod CD_FPS;
  3364. value := value div CD_FPS;
  3365. S := value mod 60;
  3366. value := value div 60;
  3367. M := value;
  3368. end;
  3369. function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer;
  3370. begin
  3371. Result := M * 60 * CD_FPS + S * CD_FPS + F;
  3372. end;
  3373. procedure SDL_VERSION(var X: TSDL_Version);
  3374. begin
  3375. X.major := SDL_MAJOR_VERSION;
  3376. X.minor := SDL_MINOR_VERSION;
  3377. X.patch := SDL_PATCHLEVEL;
  3378. end;
  3379. function SDL_VERSIONNUM(X, Y, Z: Integer): Integer;
  3380. begin
  3381. Result := X * 1000 + Y * 100 + Z;
  3382. end;
  3383. function SDL_COMPILEDVERSION: Integer;
  3384. begin
  3385. Result := SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL
  3386. );
  3387. end;
  3388. function SDL_VERSION_ATLEAST(X, Y, Z: Integer): LongBool;
  3389. begin
  3390. Result := (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z));
  3391. end;
  3392. function SDL_LoadBMP(filename: PChar): PSDL_Surface;
  3393. begin
  3394. Result := SDL_LoadBMP_RW(SDL_RWFromFile(filename, 'rb'), 1);
  3395. end;
  3396. function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer;
  3397. begin
  3398. Result := SDL_SaveBMP_RW(surface, SDL_RWFromFile(filename, 'wb'), 1);
  3399. end;
  3400. function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst:
  3401. PSDL_Surface;
  3402. dstrect: PSDL_Rect): Integer;
  3403. begin
  3404. Result := SDL_UpperBlit(src, srcrect, dst, dstrect);
  3405. end;
  3406. function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer;
  3407. RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
  3408. begin
  3409. Result := SDL_CreateRGBSurface(flags, width, height, depth, RMask, GMask,
  3410. BMask, AMask);
  3411. end;
  3412. function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  3413. begin
  3414. Result := ( ( surface^.offset <> 0 ) or
  3415. ( ( surface^.flags and ( SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL ) ) <> 0 ) );
  3416. end;
  3417. function SDL_LockMutex(mutex: PSDL_mutex): Integer;
  3418. begin
  3419. Result := SDL_mutexP(mutex);
  3420. end;
  3421. function SDL_UnlockMutex(mutex: PSDL_mutex): Integer;
  3422. begin
  3423. Result := SDL_mutexV(mutex);
  3424. end;
  3425. {$IFDEF WIN32}
  3426. function _putenv( const variable : Pchar ): Integer;
  3427. cdecl; external {$IFDEF __GPC__}name '_putenv'{$ELSE} 'MSVCRT.DLL'{$ENDIF __GPC__};
  3428. {$ENDIF}
  3429. function SDL_putenv(const variable: PChar): Integer;
  3430. begin
  3431. {$IFDEF WIN32}
  3432. Result := _putenv(variable);
  3433. {$ENDIF}
  3434. {$IFDEF UNIX}
  3435. {$IFDEF FPC}
  3436. Result := _putenv(variable);
  3437. {$ELSE}
  3438. Result := libc.putenv(variable);
  3439. {$ENDIF}
  3440. {$ENDIF}
  3441. end;
  3442. {$IFDEF WIN32}
  3443. {$IFNDEF __GPC__}
  3444. function getenv( const name : Pchar ): PChar;
  3445. cdecl; external {$IFDEF __GPC__}name 'getenv'{$ELSE} 'MSVCRT.DLL'{$ENDIF};
  3446. {$ENDIF}
  3447. {$ENDIF}
  3448. function SDL_getenv(const name: PChar): PChar;
  3449. begin
  3450. {$IFDEF WIN32}
  3451. {$IFDEF __GPC__}
  3452. Result := getenv( string( name ) );
  3453. {$ELSE}
  3454. Result := getenv( name );
  3455. {$ENDIF}
  3456. {$ELSE}
  3457. {$IFDEF UNIX}
  3458. {$IFDEF FPC}
  3459. Result := fpgetenv(name);
  3460. {$ELSE}
  3461. Result := libc.getenv(name);
  3462. {$ENDIF}
  3463. {$ENDIF}
  3464. {$ENDIF}
  3465. end;
  3466. function SDL_BUTTON( Button : Integer ) : Integer;
  3467. begin
  3468. Result := SDL_PRESSED shl ( Button - 1 );
  3469. end;
  3470. function SDL_Swap32(D: Uint32): Uint32;
  3471. begin
  3472. Result := ((D shl 24) or ((D shl 8) and $00FF0000) or ((D shr 8) and $0000FF00) or (D shr 24));
  3473. end;
  3474. procedure FreeAndNil(var Obj);
  3475. {$IFNDEF __GPC__}
  3476. {$IFNDEF __TMT__}
  3477. var
  3478. Temp: TObject;
  3479. {$ENDIF}
  3480. {$ENDIF}
  3481. begin
  3482. {$IFNDEF __GPC__}
  3483. {$IFNDEF __TMT__}
  3484. Temp := TObject(Obj);
  3485. Pointer(Obj) := nil;
  3486. Temp.Free;
  3487. {$ENDIF}
  3488. {$ENDIF}
  3489. end;
  3490. { Exit procedure handling }
  3491. type
  3492. PExitProcInfo = ^TExitProcInfo;
  3493. TExitProcInfo = record
  3494. Next: PExitProcInfo;
  3495. SaveExit: Pointer;
  3496. Proc: TProcedure;
  3497. end;
  3498. var
  3499. ExitProcList: PExitProcInfo = nil;
  3500. procedure DoExitProc;
  3501. var
  3502. P: PExitProcInfo;
  3503. Proc: TProcedure;
  3504. begin
  3505. P := ExitProcList;
  3506. ExitProcList := P^.Next;
  3507. ExitProc := P^.SaveExit;
  3508. Proc := P^.Proc;
  3509. Dispose(P);
  3510. Proc;
  3511. end;
  3512. procedure AddExitProc(Proc: TProcedure);
  3513. var
  3514. P: PExitProcInfo;
  3515. begin
  3516. New(P);
  3517. P^.Next := ExitProcList;
  3518. P^.SaveExit := ExitProc;
  3519. P^.Proc := Proc;
  3520. ExitProcList := P;
  3521. ExitProc := @DoExitProc;
  3522. end;
  3523. function IsBitOn( value : integer; bit : Byte ) : boolean;
  3524. begin
  3525. result := ( ( value and ( 1 shl bit ) ) <> 0 );
  3526. end;
  3527. function TurnBitOn( value : integer; bit : Byte ) : integer;
  3528. begin
  3529. result := ( value or ( 1 shl bit ) );
  3530. end;
  3531. function TurnBitOff( value : integer; bit : Byte ) : integer;
  3532. begin
  3533. result := ( value and not ( 1 shl bit ) );
  3534. end;
  3535. end.