sdl.pas 160 KB

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