# Module sdl

# Types

    TEventKind = enum
      NOEVENT = 0,
      ACTIVEEVENT = 1,
      KEYDOWN = 2,
      KEYUP = 3,
      MOUSEMOTION = 4,
      MOUSEBUTTONDOWN = 5,
      MOUSEBUTTONUP = 6,
      JOYAXISMOTION = 7,
      JOYBALLMOTION = 8,
      JOYHATMOTION = 9,
      JOYBUTTONDOWN = 10,
      JOYBUTTONUP = 11,
      QUITEV = 12,
      SYSWMEVENT = 13,
      EVENT_RESERVEDA = 14,
      EVENT_RESERVED = 15,
      VIDEORESIZE = 16,
      VIDEOEXPOSE = 17,
      EVENT_RESERVED2 = 18,
      EVENT_RESERVED3 = 19,
      EVENT_RESERVED4 = 20,
      EVENT_RESERVED5 = 21,
      EVENT_RESERVED6 = 22,
      EVENT_RESERVED7 = 23,
      USEREVENT = 24

    THandle = int

    TBool = enum
      sdlFALSE, sdlTRUE

    PUInt8Array = ptr TUInt8Array

    TUInt8Array = array[0 .. high(int) shr 1, Byte]

    PUInt16 = ptr uint16

    PUInt32 = ptr uint32

    PUInt64 = ptr UInt64

    UInt64 = object
      hi*: int32
      lo*: int32

    PSInt64 = ptr SInt64

    SInt64 = object
      hi*: int32
      lo*: int32

    TGrabMode = int32

    Terrorcode = enum
      ENOMEM, EFREAD, EFWRITE, EFSEEK, LASTERROR

    errorcode = Terrorcode

    TArg = object
      buf*: array[0 .. 128 - 1, int8]

    Perror = ptr Terror

    Terror = object
      error*: int
      key*: array[0 .. 128 - 1, int8]
      argc*: int
      args*: array[0 .. 5 - 1, TArg]

    TStdio = object
      autoclose*: int
      fp*: pointer

    TMem = object
      base*: ptr Byte
      here*: ptr Byte
      stop*: ptr Byte

    PRWops = ptr TRWops

    TSeek = proc (context: PRWops; offset: int; whence: int): int {.cdecl.}

    TRead = proc (context: PRWops; thePtr: pointer; size: int; maxnum: int): int {.
        cdecl.}

    TWrite = proc (context: PRWops; thePtr: pointer; size: int; num: int): int {.
        cdecl.}

    TClose = proc (context: PRWops): int {.cdecl.}

    TRWops = object
      seek*: TSeek
      read*: TRead
      write*: TWrite
      closeFile*: TClose
      theType*: cint
      mem*: TMem

    RWops = TRWops

    TTimerCallback = proc (interval: int32): int32 {.cdecl.}

    TNewTimerCallback = proc (interval: int32; param: pointer): int32 {.cdecl.}

    PTimerID = ptr TTimerID

    TTimerID = object
      interval*: int32
      callback*: TNewTimerCallback
      param*: pointer
      last_alarm*: int32
      next*: PTimerID

    TAudioSpecCallback = proc (userdata: pointer; stream: ptr Byte; length: int) {.
        cdecl.}

    PAudioSpec = ptr TAudioSpec

    TAudioSpec = object
      freq*: int
      format*: uint16
      channels*: Byte
      silence*: Byte
      samples*: uint16
      padding*: uint16
      size*: int32
      callback*: TAudioSpecCallback
      userdata*: pointer

    PAudioCVT = ptr TAudioCVT

    PAudioCVTFilter = ptr TAudioCVTFilter

    TAudioCVTFilter = object
      cvt*: PAudioCVT
      format*: uint16

    PAudioCVTFilterArray = ptr TAudioCVTFilterArray

    TAudioCVTFilterArray = array[0 .. 9, PAudioCVTFilter]

    TAudioCVT = object
      needed*: int
      src_format*: uint16
      dst_format*: uint16
      rate_incr*: float64
      buf*: ptr Byte
      length*: int
      len_cvt*: int
      len_mult*: int
      len_ratio*: float64
      filters*: TAudioCVTFilterArray
      filter_index*: int

    TAudiostatus = enum
      AUDIO_STOPPED, AUDIO_PLAYING, AUDIO_PAUSED

    TCDStatus = enum
      CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED

    PCDTrack = ptr TCDTrack

    TCDTrack = object
      id*: Byte
      theType*: Byte
      unused*: uint16
      len*: int32
      offset*: int32

    PCD = ptr TCD

    TCD = object
      id*: int
      status*: TCDStatus
      numtracks*: int
      cur_track*: int
      cur_frame*: int
      track*: array[0 .. MAX_TRACKS, TCDTrack]

    PTransAxis = ptr TTransAxis

    TTransAxis = object
      offset*: int
      scale*: float32

    PJoystick_hwdata = ptr TJoystick_hwdata

    TJoystick_hwdata = object
      id*: int
      transaxis*: array[0 .. 5, TTransAxis]

    PBallDelta = ptr TBallDelta

    TBallDelta = object
      dx*: int
      dy*: int

    PJoystick = ptr TJoystick

    TJoystick = object
      index*: Byte
      name*: cstring
      naxes*: int
      axes*: PUInt16
      nhats*: int
      hats*: ptr Byte
      nballs*: int
      balls*: PBallDelta
      nbuttons*: int
      buttons*: ptr Byte
      hwdata*: PJoystick_hwdata
      ref_count*: int

    Pversion = ptr Tversion

    Tversion = object
      major*: Byte
      minor*: Byte
      patch*: Byte

    TKey = int32

    TMod = int32

    PKeySym = ptr TKeySym

    TKeySym = object
      scancode*: Byte
      sym*: TKey
      modifier*: TMod
      unicode*: uint16

    TEventAction = enum
      ADDEVENT, PEEKEVENT, GETEVENT

    PActiveEvent = ptr TActiveEvent

    TActiveEvent = object
      kind*: TEventKind
      gain*: Byte
      state*: Byte

    TKeyboardEvent = object
      kind*: TEventKind
      which*: Byte
      state*: Byte
      keysym*: TKeySym

    TMouseMotionEvent = object
      kind*: TEventKind
      which*: Byte
      state*: Byte
      x*, y*: uint16
      xrel*: int16
      yrel*: int16

    TMouseButtonEvent = object
      kind*: TEventKind
      which*: Byte
      button*: Byte
      state*: Byte
      x*: uint16
      y*: uint16

    TJoyAxisEvent = object
      kind*: TEventKind
      which*: Byte
      axis*: Byte
      value*: int16

    TJoyBallEvent = object
      kind*: TEventKind
      which*: Byte
      ball*: Byte
      xrel*: int16
      yrel*: int16

    TJoyHatEvent = object
      kind*: TEventKind
      which*: Byte
      hat*: Byte
      value*: Byte

    TJoyButtonEvent = object
      kind*: TEventKind
      which*: Byte
      button*: Byte
      state*: Byte

    TResizeEvent = object
      kind*: TEventKind
      w*: cint
      h*: cint

    PUserEvent = ptr TUserEvent

    TUserEvent = object
      kind*: TEventKind
      code*: cint
      data1*: pointer
      data2*: pointer

    TSysWm = enum
      SYSWM_X11

    PSysWMmsg = ptr TSysWMmsg

    TSysWMmsg = object
      version*: Tversion
      subsystem*: TSysWm
      when false:
          event*: TXEvent

    TX11 = object
      when false:
          display*: PDisplay
          window*: TWindow
          lock_func*: Pointer
          unlock_func*: Pointer
          fswindow*: TWindow
          wmwindow*: TWindow

    PSysWMinfo = ptr TSysWMinfo

    TSysWMinfo = object
      version*: Tversion
      subsystem*: TSysWm
      X11*: TX11

    PSysWMEvent = ptr TSysWMEvent

    TSysWMEvent = object
      kind*: TEventKind
      msg*: PSysWMmsg

    TExposeEvent = object
      kind*: TEventKind

    TQuitEvent = object
      kind*: TEventKind

    PEvent = ptr TEvent

    TEvent = object
      kind*: TEventKind
      pad: array[0 .. 19, Byte]

    TEventFilter = proc (event: PEvent): int {.cdecl.}

    PPSDL_Rect = ptr PRect

    PRect = ptr TRect

    TRect = object
      x*, y*: int16
      w*, h*: uint16

    Rect = TRect

    PColor = ptr TColor

    TColor = object
      r*: Byte
      g*: Byte
      b*: Byte
      unused*: Byte

    PColorArray = ptr TColorArray

    TColorArray = array[0 .. 65000, TColor]

    PPalette = ptr TPalette

    TPalette = object
      ncolors*: int
      colors*: PColorArray

    PPixelFormat = ptr TPixelFormat

    TPixelFormat = object
      palette*: PPalette
      BitsPerPixel*: Byte
      BytesPerPixel*: Byte
      Rloss*: Byte
      Gloss*: Byte
      Bloss*: Byte
      Aloss*: Byte
      Rshift*: Byte
      Gshift*: Byte
      Bshift*: Byte
      Ashift*: Byte
      RMask*: int32
      GMask*: int32
      BMask*: int32
      AMask*: int32
      colorkey*: int32
      alpha*: Byte

    PBlitInfo = ptr TBlitInfo

    TBlitInfo = object
      s_pixels*: ptr Byte
      s_width*: int
      s_height*: int
      s_skip*: int
      d_pixels*: ptr Byte
      d_width*: int
      d_height*: int
      d_skip*: int
      aux_data*: pointer
      src*: PPixelFormat
      table*: ptr Byte
      dst*: PPixelFormat

    PSurface = ptr TSurface

    TBlit = proc (src: PSurface; srcrect: PRect; dst: PSurface; dstrect: PRect): int {.
        cdecl.}

    TSurface = object
      flags*: int32
      format*: PPixelFormat
      w*, h*: cint
      pitch*: uint16
      pixels*: pointer
      offset*: cint
      hwdata*: pointer
      clip_rect*: TRect
      unused1*: int32
      locked*: int32
      Blitmap*: pointer
      format_version*: cint
      refcount*: cint

    PVideoInfo = ptr TVideoInfo

    TVideoInfo = object
      hw_available*: Byte
      blit_hw*: Byte
      UnusedBits3*: Byte
      video_mem*: int32
      vfmt*: PPixelFormat
      current_w*: int32
      current_h*: int32

    POverlay = ptr TOverlay

    TOverlay = object
      format*: int32
      w*, h*: int
      planes*: int
      pitches*: PUInt16
      pixels*: ptr ptr Byte
      hw_overlay*: int32

    TGLAttr = enum
      GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE,
      GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
      GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO,
      GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL,
      GL_SWAP_CONTROL

    PCursor = ptr TCursor

    TCursor = object
      area*: TRect
      hot_x*, hot_y*: int16
      data*: ptr Byte
      mask*: ptr Byte
      save*: array[1 .. 2, ptr Byte]
      wm_cursor*: pointer

    PMutex = ptr TMutex

    TMutex = object

    Psemaphore = ptr Tsemaphore

    Tsemaphore = object

    PSem = ptr TSem

    TSem = Tsemaphore

    PCond = ptr TCond

    TCond = object

    TSYS_ThreadHandle = pointer

    PThread = ptr TThread

    TThread = object
      threadid*: int32
      handle*: TSYS_ThreadHandle
      status*: int
      errbuf*: Terror
      data*: pointer

    PKeyStateArr = ptr TKeyStateArr

    TKeyStateArr = array[0 .. 65000, Byte]

    PInteger = ptr int

    PByte = ptr int8

    PWord = ptr int16

    PLongWord = ptr int32

    PByteArray = ptr TByteArray

    TByteArray = array[0 .. 32767, int8]

    PWordArray = ptr TWordArray

    TWordArray = array[0 .. 16383, int16]

# Consts

    MAJOR_VERSION = 1

    MINOR_VERSION = 2

    PATCHLEVEL = 11

    INIT_TIMER = 0x00000001

    INIT_AUDIO = 0x00000010

    INIT_VIDEO = 0x00000020

    INIT_CDROM = 0x00000100

    INIT_JOYSTICK = 0x00000200

    INIT_NOPARACHUTE = 0x00100000

    INIT_EVENTTHREAD = 0x01000000

    INIT_EVERYTHING = 0x0000FFFF

    ERR_MAX_STRLEN = 128

    ERR_MAX_ARGS = 5

    PRESSED = 0x00000001

    RELEASED = 0x00000000

    TIMESLICE = 10

    TIMER_RESOLUTION = 10

    AUDIO_U8 = 0x00000008

    AUDIO_S8 = 0x00008008

    AUDIO_U16LSB = 0x00000010

    AUDIO_S16LSB = 0x00008010

    AUDIO_U16MSB = 0x00001010

    AUDIO_S16MSB = 0x00009010

    AUDIO_U16 = 0x00000010

    AUDIO_S16 = 0x00008010

    MAX_TRACKS = 99

    AUDIO_TRACK = 0x00000000

    DATA_TRACK = 0x00000004

    CD_FPS = 75

    LIL_ENDIAN = 1234

    BIG_ENDIAN = 4321

    BYTEORDER = 1234

    AUDIO_U16SYS = 0x00000010

    AUDIO_S16SYS = 0x00008010

    MIX_MAXVOLUME = 128

    MAX_JOYSTICKS = 2

    MAX_AXES = 6

    MAX_BUTTONS = 32

    AXIS_MIN = -32768

    AXIS_MAX = 32767

    JOY_AXIS_THRESHOLD = 6.5535000000000002e+02

    HAT_CENTERED = 0x00000000

    HAT_UP = 0x00000001

    HAT_RIGHT = 0x00000002

    HAT_DOWN = 0x00000004

    HAT_LEFT = 0x00000008

    HAT_RIGHTUP = 3

    HAT_RIGHTDOWN = 6

    HAT_LEFTUP = 9

    HAT_LEFTDOWN = 12

    NUMEVENTS = 32

    ALLEVENTS = 0xFFFFFFFF

    ACTIVEEVENTMASK = 2

    KEYDOWNMASK = 4

    KEYUPMASK = 8

    MOUSEMOTIONMASK = 16

    MOUSEBUTTONDOWNMASK = 32

    MOUSEBUTTONUPMASK = 64

    MOUSEEVENTMASK = 112

    JOYAXISMOTIONMASK = 128

    JOYBALLMOTIONMASK = 256

    JOYHATMOTIONMASK = 512

    JOYBUTTONDOWNMASK = 1024

    JOYBUTTONUPMASK = 2048

    JOYEVENTMASK = 3968

    VIDEORESIZEMASK = 65536

    QUITMASK = 4096

    SYSWMEVENTMASK = 8192

    QUERY = -1

    IGNORE = 0

    DISABLE = 0

    ENABLE = 1

    ALL_HOTKEYS = 0xFFFFFFFF

    DEFAULT_REPEAT_DELAY = 500

    DEFAULT_REPEAT_INTERVAL = 30

    K_UNKNOWN = 0

    K_FIRST = 0

    K_BACKSPACE = 8

    K_TAB = 9

    K_CLEAR = 12

    K_RETURN = 13

    K_PAUSE = 19

    K_ESCAPE = 27

    K_SPACE = 32

    K_EXCLAIM = 33

    K_QUOTEDBL = 34

    K_HASH = 35

    K_DOLLAR = 36

    K_AMPERSAND = 38

    K_QUOTE = 39

    K_LEFTPAREN = 40

    K_RIGHTPAREN = 41

    K_ASTERISK = 42

    K_PLUS = 43

    K_COMMA = 44

    K_MINUS = 45

    K_PERIOD = 46

    K_SLASH = 47

    K_0 = 48

    K_1 = 49

    K_2 = 50

    K_3 = 51

    K_4 = 52

    K_5 = 53

    K_6 = 54

    K_7 = 55

    K_8 = 56

    K_9 = 57

    K_COLON = 58

    K_SEMICOLON = 59

    K_LESS = 60

    K_EQUALS = 61

    K_GREATER = 62

    K_QUESTION = 63

    K_AT = 64

    K_LEFTBRACKET = 91

    K_BACKSLASH = 92

    K_RIGHTBRACKET = 93

    K_CARET = 94

    K_UNDERSCORE = 95

    K_BACKQUOTE = 96

    K_a = 97

    K_b = 98

    K_c = 99

    K_d = 100

    K_e = 101

    K_f = 102

    K_g = 103

    K_h = 104

    K_i = 105

    K_j = 106

    K_k = 107

    K_l = 108

    K_m = 109

    K_n = 110

    K_o = 111

    K_p = 112

    K_q = 113

    K_r = 114

    K_s = 115

    K_t = 116

    K_u = 117

    K_v = 118

    K_w = 119

    K_x = 120

    K_y = 121

    K_z = 122

    K_DELETE = 127

    K_WORLD_0 = 160

    K_WORLD_1 = 161

    K_WORLD_2 = 162

    K_WORLD_3 = 163

    K_WORLD_4 = 164

    K_WORLD_5 = 165

    K_WORLD_6 = 166

    K_WORLD_7 = 167

    K_WORLD_8 = 168

    K_WORLD_9 = 169

    K_WORLD_10 = 170

    K_WORLD_11 = 171

    K_WORLD_12 = 172

    K_WORLD_13 = 173

    K_WORLD_14 = 174

    K_WORLD_15 = 175

    K_WORLD_16 = 176

    K_WORLD_17 = 177

    K_WORLD_18 = 178

    K_WORLD_19 = 179

    K_WORLD_20 = 180

    K_WORLD_21 = 181

    K_WORLD_22 = 182

    K_WORLD_23 = 183

    K_WORLD_24 = 184

    K_WORLD_25 = 185

    K_WORLD_26 = 186

    K_WORLD_27 = 187

    K_WORLD_28 = 188

    K_WORLD_29 = 189

    K_WORLD_30 = 190

    K_WORLD_31 = 191

    K_WORLD_32 = 192

    K_WORLD_33 = 193

    K_WORLD_34 = 194

    K_WORLD_35 = 195

    K_WORLD_36 = 196

    K_WORLD_37 = 197

    K_WORLD_38 = 198

    K_WORLD_39 = 199

    K_WORLD_40 = 200

    K_WORLD_41 = 201

    K_WORLD_42 = 202

    K_WORLD_43 = 203

    K_WORLD_44 = 204

    K_WORLD_45 = 205

    K_WORLD_46 = 206

    K_WORLD_47 = 207

    K_WORLD_48 = 208

    K_WORLD_49 = 209

    K_WORLD_50 = 210

    K_WORLD_51 = 211

    K_WORLD_52 = 212

    K_WORLD_53 = 213

    K_WORLD_54 = 214

    K_WORLD_55 = 215

    K_WORLD_56 = 216

    K_WORLD_57 = 217

    K_WORLD_58 = 218

    K_WORLD_59 = 219

    K_WORLD_60 = 220

    K_WORLD_61 = 221

    K_WORLD_62 = 222

    K_WORLD_63 = 223

    K_WORLD_64 = 224

    K_WORLD_65 = 225

    K_WORLD_66 = 226

    K_WORLD_67 = 227

    K_WORLD_68 = 228

    K_WORLD_69 = 229

    K_WORLD_70 = 230

    K_WORLD_71 = 231

    K_WORLD_72 = 232

    K_WORLD_73 = 233

    K_WORLD_74 = 234

    K_WORLD_75 = 235

    K_WORLD_76 = 236

    K_WORLD_77 = 237

    K_WORLD_78 = 238

    K_WORLD_79 = 239

    K_WORLD_80 = 240

    K_WORLD_81 = 241

    K_WORLD_82 = 242

    K_WORLD_83 = 243

    K_WORLD_84 = 244

    K_WORLD_85 = 245

    K_WORLD_86 = 246

    K_WORLD_87 = 247

    K_WORLD_88 = 248

    K_WORLD_89 = 249

    K_WORLD_90 = 250

    K_WORLD_91 = 251

    K_WORLD_92 = 252

    K_WORLD_93 = 253

    K_WORLD_94 = 254

    K_WORLD_95 = 255

    K_KP0 = 256

    K_KP1 = 257

    K_KP2 = 258

    K_KP3 = 259

    K_KP4 = 260

    K_KP5 = 261

    K_KP6 = 262

    K_KP7 = 263

    K_KP8 = 264

    K_KP9 = 265

    K_KP_PERIOD = 266

    K_KP_DIVIDE = 267

    K_KP_MULTIPLY = 268

    K_KP_MINUS = 269

    K_KP_PLUS = 270

    K_KP_ENTER = 271

    K_KP_EQUALS = 272

    K_UP = 273

    K_DOWN = 274

    K_RIGHT = 275

    K_LEFT = 276

    K_INSERT = 277

    K_HOME = 278

    K_END = 279

    K_PAGEUP = 280

    K_PAGEDOWN = 281

    K_F1 = 282

    K_F2 = 283

    K_F3 = 284

    K_F4 = 285

    K_F5 = 286

    K_F6 = 287

    K_F7 = 288

    K_F8 = 289

    K_F9 = 290

    K_F10 = 291

    K_F11 = 292

    K_F12 = 293

    K_F13 = 294

    K_F14 = 295

    K_F15 = 296

    K_NUMLOCK = 300

    K_CAPSLOCK = 301

    K_SCROLLOCK = 302

    K_RSHIFT = 303

    K_LSHIFT = 304

    K_RCTRL = 305

    K_LCTRL = 306

    K_RALT = 307

    K_LALT = 308

    K_RMETA = 309

    K_LMETA = 310

    K_LSUPER = 311

    K_RSUPER = 312

    K_MODE = 313

    K_COMPOSE = 314

    K_HELP = 315

    K_PRINT = 316

    K_SYSREQ = 317

    K_BREAK = 318

    K_MENU = 319

    K_POWER = 320

    K_EURO = 321

    K_GP2X_UP = 0

    K_GP2X_UPLEFT = 1

    K_GP2X_LEFT = 2

    K_GP2X_DOWNLEFT = 3

    K_GP2X_DOWN = 4

    K_GP2X_DOWNRIGHT = 5

    K_GP2X_RIGHT = 6

    K_GP2X_UPRIGHT = 7

    K_GP2X_START = 8

    K_GP2X_SELECT = 9

    K_GP2X_L = 10

    K_GP2X_R = 11

    K_GP2X_A = 12

    K_GP2X_B = 13

    K_GP2X_Y = 14

    K_GP2X_X = 15

    K_GP2X_VOLUP = 16

    K_GP2X_VOLDOWN = 17

    K_GP2X_CLICK = 18

    KMOD_NONE = 0x00000000

    KMOD_LSHIFT = 0x00000001

    KMOD_RSHIFT = 0x00000002

    KMOD_LCTRL = 0x00000040

    KMOD_RCTRL = 0x00000080

    KMOD_LALT = 0x00000100

    KMOD_RALT = 0x00000200

    KMOD_LMETA = 0x00000400

    KMOD_RMETA = 0x00000800

    KMOD_NUM = 0x00001000

    KMOD_CAPS = 0x00002000

    KMOD_MODE = 44000

    KMOD_RESERVED = 0x00008000

    KMOD_CTRL = 192

    KMOD_SHIFT = 3

    KMOD_ALT = 768

    KMOD_META = 3072

    ALPHA_OPAQUE = 255

    ALPHA_TRANSPARENT = 0

    SWSURFACE = 0x00000000

    HWSURFACE = 0x00000001

    ASYNCBLIT = 0x00000004

    ANYFORMAT = 0x10000000

    HWPALETTE = 0x20000000

    DOUBLEBUF = 0x40000000

    FULLSCREEN = 0x80000000

    OPENGL = 0x00000002

    OPENGLBLIT = 0x00000002

    RESIZABLE = 0x00000010

    NOFRAME = 0x00000020

    HWACCEL = 0x00000100

    SRCCOLORKEY = 0x00001000

    RLEACCELOK = 0x00002000

    RLEACCEL = 0x00004000

    SRCALPHA = 0x00010000

    SRCCLIPPING = 0x00100000

    PREALLOC = 0x01000000

    YV12_OVERLAY = 0x32315659

    IYUV_OVERLAY = 0x56555949

    YUY2_OVERLAY = 0x32595559

    UYVY_OVERLAY = 0x59565955

    YVYU_OVERLAY = 0x55595659

    LOGPAL = 0x00000001

    PHYSPAL = 0x00000002

    BUTTON_LEFT = 1

    BUTTON_MIDDLE = 2

    BUTTON_RIGHT = 3

    BUTTON_WHEELUP = 4

    BUTTON_WHEELDOWN = 5

    BUTTON_LMASK = 1

    BUTTON_MMASK = 2

    BUTTON_RMask = 4

    APPMOUSEFOCUS = 0x00000001

    APPINPUTFOCUS = 0x00000002

    APPACTIVE = 0x00000004

    MUTEX_TIMEDOUT = 1

    MUTEX_MAXWAIT = -1

    GRAB_QUERY = -1

    GRAB_OFF = 0

    GRAB_ON = 1

# Procs

    proc EvActive(event: PEvent): PActiveEvent {.raises: [], tags: [].}

    proc EvKeyboard(event: PEvent): PKeyboardEvent {.raises: [], tags: [].}

    proc EvMouseMotion(event: PEvent): PMouseMotionEvent {.raises: [], tags: [].}

    proc EvMouseButton(event: PEvent): PMouseButtonEvent {.raises: [], tags: [].}

    proc EvJoyAxis(event: PEvent): PJoyAxisEvent {.raises: [], tags: [].}

    proc EvJoyBall(event: PEvent): PJoyBallEvent {.raises: [], tags: [].}

    proc EvJoyHat(event: PEvent): PJoyHatEvent {.raises: [], tags: [].}

    proc EvJoyButton(event: PEvent): PJoyButtonEvent {.raises: [], tags: [].}

    proc EvResize(event: PEvent): PResizeEvent {.raises: [], tags: [].}

    proc EvExpose(event: PEvent): PExposeEvent {.raises: [], tags: [].}

    proc EvQuit(event: PEvent): PQuitEvent {.raises: [], tags: [].}

    proc EvUser(event: PEvent): PUserEvent {.raises: [], tags: [].}

    proc EvSysWM(event: PEvent): PSysWMEvent {.raises: [], tags: [].}

    proc Init(flags: int32): int {.cdecl, importc: "SDL_Init", dynlib: LibName.}

    proc InitSubSystem(flags: int32): int {.cdecl, importc: "SDL_InitSubSystem",
                                            dynlib: LibName.}

    proc QuitSubSystem(flags: int32) {.cdecl, importc: "SDL_QuitSubSystem",
                                       dynlib: LibName.}

    proc WasInit(flags: int32): int32 {.cdecl, importc: "SDL_WasInit",
                                        dynlib: LibName.}

    proc Quit() {.cdecl, importc: "SDL_Quit", dynlib: LibName.}

    proc GetError(): cstring {.cdecl, importc: "SDL_GetError", dynlib: LibName.}

    proc SetError(fmt: cstring) {.cdecl, importc: "SDL_SetError", dynlib: LibName.}

    proc ClearError() {.cdecl, importc: "SDL_ClearError", dynlib: LibName.}

    proc Error(Code: Terrorcode) {.cdecl, importc: "SDL_Error", dynlib: LibName.}

    proc RWFromFile(filename, mode: cstring): PRWops {.cdecl,
        importc: "SDL_RWFromFile", dynlib: LibName.}

    proc FreeRW(area: PRWops) {.cdecl, importc: "SDL_FreeRW", dynlib: LibName.}

    proc RWFromFP(fp: pointer; autoclose: int): PRWops {.cdecl,
        importc: "SDL_RWFromFP", dynlib: LibName.}

    proc RWFromMem(mem: pointer; size: int): PRWops {.cdecl,
        importc: "SDL_RWFromMem", dynlib: LibName.}

    proc RWFromConstMem(mem: pointer; size: int): PRWops {.cdecl,
        importc: "SDL_RWFromConstMem", dynlib: LibName.}

    proc AllocRW(): PRWops {.cdecl, importc: "SDL_AllocRW", dynlib: LibName.}

    proc GetTicks(): int32 {.cdecl, importc: "SDL_GetTicks", dynlib: LibName.}

    proc Delay(msec: int32) {.cdecl, importc: "SDL_Delay", dynlib: LibName.}

    proc AddTimer(interval: int32; callback: TNewTimerCallback; param: pointer): PTimerID {.
        cdecl, importc: "SDL_AddTimer", dynlib: LibName.}

    proc RemoveTimer(t: PTimerID): TBool {.cdecl, importc: "SDL_RemoveTimer",
                                           dynlib: LibName.}

    proc SetTimer(interval: int32; callback: TTimerCallback): int {.cdecl,
        importc: "SDL_SetTimer", dynlib: LibName.}

    proc AudioInit(driver_name: cstring): int {.cdecl, importc: "SDL_AudioInit",
        dynlib: LibName.}

    proc AudioQuit() {.cdecl, importc: "SDL_AudioQuit", dynlib: LibName.}

    proc AudioDriverName(namebuf: cstring; maxlen: int): cstring {.cdecl,
        importc: "SDL_AudioDriverName", dynlib: LibName.}

    proc OpenAudio(desired, obtained: PAudioSpec): int {.cdecl,
        importc: "SDL_OpenAudio", dynlib: LibName.}

    proc GetAudioStatus(): TAudiostatus {.cdecl, importc: "SDL_GetAudioStatus",
                                          dynlib: LibName.}

    proc PauseAudio(pause_on: int) {.cdecl, importc: "SDL_PauseAudio",
                                     dynlib: LibName.}

    proc LoadWAV_RW(src: PRWops; freesrc: int; spec: PAudioSpec;
                    audio_buf: ptr Byte; audiolen: PUInt32): PAudioSpec {.cdecl,
        importc: "SDL_LoadWAV_RW", dynlib: LibName.}

    proc FreeWAV(audio_buf: ptr Byte) {.cdecl, importc: "SDL_FreeWAV",
                                        dynlib: LibName.}

    proc BuildAudioCVT(cvt: PAudioCVT; src_format: uint16; src_channels: Byte;
                       src_rate: int; dst_format: uint16; dst_channels: Byte;
                       dst_rate: int): int {.cdecl, importc: "SDL_BuildAudioCVT",
        dynlib: LibName.}

    proc ConvertAudio(cvt: PAudioCVT): int {.cdecl, importc: "SDL_ConvertAudio",
        dynlib: LibName.}

    proc MixAudio(dst, src: ptr Byte; length: int32; volume: int) {.cdecl,
        importc: "SDL_MixAudio", dynlib: LibName.}

    proc LockAudio() {.cdecl, importc: "SDL_LockAudio", dynlib: LibName.}

    proc UnlockAudio() {.cdecl, importc: "SDL_UnlockAudio", dynlib: LibName.}

    proc CloseAudio() {.cdecl, importc: "SDL_CloseAudio", dynlib: LibName.}

    proc CDNumDrives(): int {.cdecl, importc: "SDL_CDNumDrives", dynlib: LibName.}

    proc CDName(drive: int): cstring {.cdecl, importc: "SDL_CDName", dynlib: LibName.}

    proc CDOpen(drive: int): PCD {.cdecl, importc: "SDL_CDOpen", dynlib: LibName.}

    proc CDStatus(cdrom: PCD): TCDStatus {.cdecl, importc: "SDL_CDStatus",
                                           dynlib: LibName.}

    proc CDPlayTracks(cdrom: PCD; start_track: int; start_frame: int; ntracks: int;
                      nframes: int): int {.cdecl, importc: "SDL_CDPlayTracks",
                                           dynlib: LibName.}

    proc CDPlay(cdrom: PCD; start: int; len: int): int {.cdecl,
        importc: "SDL_CDPlay", dynlib: LibName.}

    proc CDPause(cdrom: PCD): int {.cdecl, importc: "SDL_CDPause", dynlib: LibName.}

    proc CDResume(cdrom: PCD): int {.cdecl, importc: "SDL_CDResume", dynlib: LibName.}

    proc CDStop(cdrom: PCD): int {.cdecl, importc: "SDL_CDStop", dynlib: LibName.}

    proc CDEject(cdrom: PCD): int {.cdecl, importc: "SDL_CDEject", dynlib: LibName.}

    proc CDClose(cdrom: PCD) {.cdecl, importc: "SDL_CDClose", dynlib: LibName.}

    proc NumJoysticks(): int {.cdecl, importc: "SDL_NumJoysticks", dynlib: LibName.}

    proc JoystickName(index: int): cstring {.cdecl, importc: "SDL_JoystickName",
        dynlib: LibName.}

    proc JoystickOpen(index: int): PJoystick {.cdecl, importc: "SDL_JoystickOpen",
        dynlib: LibName.}

    proc JoystickOpened(index: int): int {.cdecl, importc: "SDL_JoystickOpened",
                                           dynlib: LibName.}

    proc JoystickIndex(joystick: PJoystick): int {.cdecl,
        importc: "SDL_JoystickIndex", dynlib: LibName.}

    proc JoystickNumAxes(joystick: PJoystick): int {.cdecl,
        importc: "SDL_JoystickNumAxes", dynlib: LibName.}

    proc JoystickNumBalls(joystick: PJoystick): int {.cdecl,
        importc: "SDL_JoystickNumBalls", dynlib: LibName.}

    proc JoystickNumHats(joystick: PJoystick): int {.cdecl,
        importc: "SDL_JoystickNumHats", dynlib: LibName.}

    proc JoystickNumButtons(joystick: PJoystick): int {.cdecl,
        importc: "SDL_JoystickNumButtons", dynlib: LibName.}

    proc JoystickUpdate() {.cdecl, importc: "SDL_JoystickUpdate", dynlib: LibName.}

    proc JoystickEventState(state: int): int {.cdecl,
        importc: "SDL_JoystickEventState", dynlib: LibName.}

    proc JoystickGetAxis(joystick: PJoystick; axis: int): int16 {.cdecl,
        importc: "SDL_JoystickGetAxis", dynlib: LibName.}

    proc JoystickGetHat(joystick: PJoystick; hat: int): Byte {.cdecl,
        importc: "SDL_JoystickGetHat", dynlib: LibName.}

    proc JoystickGetBall(joystick: PJoystick; ball: int; dx: var int; dy: var int): int {.
        cdecl, importc: "SDL_JoystickGetBall", dynlib: LibName.}

    proc JoystickGetButton(joystick: PJoystick; Button: int): Byte {.cdecl,
        importc: "SDL_JoystickGetButton", dynlib: LibName.}

    proc JoystickClose(joystick: PJoystick) {.cdecl, importc: "SDL_JoystickClose",
        dynlib: LibName.}

    proc PumpEvents() {.cdecl, importc: "SDL_PumpEvents", dynlib: LibName.}

    proc PeepEvents(events: PEvent; numevents: int; action: TEventAction;
                    mask: int32): int {.cdecl, importc: "SDL_PeepEvents",
                                        dynlib: LibName.}

    proc PollEvent(event: PEvent): int {.cdecl, importc: "SDL_PollEvent",
                                         dynlib: LibName.}

    proc WaitEvent(event: PEvent): int {.cdecl, importc: "SDL_WaitEvent",
                                         dynlib: LibName.}

    proc PushEvent(event: PEvent): int {.cdecl, importc: "SDL_PushEvent",
                                         dynlib: LibName.}

    proc SetEventFilter(filter: TEventFilter) {.cdecl,
        importc: "SDL_SetEventFilter", dynlib: LibName.}

    proc GetEventFilter(): TEventFilter {.cdecl, importc: "SDL_GetEventFilter",
                                          dynlib: LibName.}

    proc EventState(theType: Byte; state: int): Byte {.cdecl,
        importc: "SDL_EventState", dynlib: LibName.}

    proc Linked_Version(): Pversion {.cdecl, importc: "SDL_Linked_Version",
                                      dynlib: LibName.}

    proc VideoInit(driver_name: cstring; flags: int32): int {.cdecl,
        importc: "SDL_VideoInit", dynlib: LibName.}

    proc VideoQuit() {.cdecl, importc: "SDL_VideoQuit", dynlib: LibName.}

    proc VideoDriverName(namebuf: cstring; maxlen: int): cstring {.cdecl,
        importc: "SDL_VideoDriverName", dynlib: LibName.}

    proc GetVideoSurface(): PSurface {.cdecl, importc: "SDL_GetVideoSurface",
                                       dynlib: LibName.}

    proc GetVideoInfo(): PVideoInfo {.cdecl, importc: "SDL_GetVideoInfo",
                                      dynlib: LibName.}

    proc VideoModeOK(width, height, bpp: int; flags: int32): int {.cdecl,
        importc: "SDL_VideoModeOK", importc: "SDL_VideoModeOK", dynlib: LibName.}

    proc ListModes(format: PPixelFormat; flags: int32): PPSDL_Rect {.cdecl,
        importc: "SDL_ListModes", dynlib: LibName.}

    proc SetVideoMode(width, height, bpp: int; flags: int32): PSurface {.cdecl,
        importc: "SDL_SetVideoMode", dynlib: LibName.}

    proc UpdateRects(screen: PSurface; numrects: int; rects: PRect) {.cdecl,
        importc: "SDL_UpdateRects", dynlib: LibName.}

    proc UpdateRect(screen: PSurface; x, y: int32; w, h: int32) {.cdecl,
        importc: "SDL_UpdateRect", dynlib: LibName.}

    proc Flip(screen: PSurface): int {.cdecl, importc: "SDL_Flip", dynlib: LibName.}

    proc SetGamma(redgamma: float32; greengamma: float32; bluegamma: float32): int {.
        cdecl, importc: "SDL_SetGamma", dynlib: LibName.}

    proc SetGammaRamp(redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): int {.
        cdecl, importc: "SDL_SetGammaRamp", dynlib: LibName.}

    proc GetGammaRamp(redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): int {.
        cdecl, importc: "SDL_GetGammaRamp", dynlib: LibName.}

    proc SetColors(surface: PSurface; colors: PColor; firstcolor: int; ncolors: int): int {.
        cdecl, importc: "SDL_SetColors", dynlib: LibName.}

    proc SetPalette(surface: PSurface; flags: int; colors: PColor; firstcolor: int;
                    ncolors: int): int {.cdecl, importc: "SDL_SetPalette",
                                         dynlib: LibName.}

    proc MapRGB(format: PPixelFormat; r: Byte; g: Byte; b: Byte): int32 {.cdecl,
        importc: "SDL_MapRGB", dynlib: LibName.}

    proc MapRGBA(format: PPixelFormat; r: Byte; g: Byte; b: Byte; a: Byte): int32 {.
        cdecl, importc: "SDL_MapRGBA", dynlib: LibName.}

    proc GetRGB(pixel: int32; fmt: PPixelFormat; r: ptr Byte; g: ptr Byte;
                b: ptr Byte) {.cdecl, importc: "SDL_GetRGB", dynlib: LibName.}

    proc GetRGBA(pixel: int32; fmt: PPixelFormat; r: ptr Byte; g: ptr Byte;
                 b: ptr Byte; a: ptr Byte) {.cdecl, importc: "SDL_GetRGBA",
        dynlib: LibName.}

    proc CreateRGBSurface(flags: int32; width, height, depth: int;
                          RMask, GMask, BMask, AMask: int32): PSurface {.cdecl,
        importc: "SDL_CreateRGBSurface", dynlib: LibName.}

    proc CreateRGBSurfaceFrom(pixels: pointer; width, height, depth, pitch: int;
                              RMask, GMask, BMask, AMask: int32): PSurface {.cdecl,
        importc: "SDL_CreateRGBSurfaceFrom", dynlib: LibName.}

    proc FreeSurface(surface: PSurface) {.cdecl, importc: "SDL_FreeSurface",
                                          dynlib: LibName.}

    proc LockSurface(surface: PSurface): int {.cdecl, importc: "SDL_LockSurface",
        dynlib: LibName.}

    proc UnlockSurface(surface: PSurface) {.cdecl, importc: "SDL_UnlockSurface",
                                            dynlib: LibName.}

    proc LoadBMP_RW(src: PRWops; freesrc: int): PSurface {.cdecl,
        importc: "SDL_LoadBMP_RW", dynlib: LibName.}

    proc SaveBMP_RW(surface: PSurface; dst: PRWops; freedst: int): int {.cdecl,
        importc: "SDL_SaveBMP_RW", dynlib: LibName.}

    proc SetColorKey(surface: PSurface; flag, key: int32): int {.cdecl,
        importc: "SDL_SetColorKey", dynlib: LibName.}

    proc SetAlpha(surface: PSurface; flag: int32; alpha: Byte): int {.cdecl,
        importc: "SDL_SetAlpha", dynlib: LibName.}

    proc SetClipRect(surface: PSurface; rect: PRect) {.cdecl,
        importc: "SDL_SetClipRect", dynlib: LibName.}

    proc GetClipRect(surface: PSurface; rect: PRect) {.cdecl,
        importc: "SDL_GetClipRect", dynlib: LibName.}

    proc ConvertSurface(src: PSurface; fmt: PPixelFormat; flags: int32): PSurface {.
        cdecl, importc: "SDL_ConvertSurface", dynlib: LibName.}

    proc UpperBlit(src: PSurface; srcrect: PRect; dst: PSurface; dstrect: PRect): int {.
        cdecl, importc: "SDL_UpperBlit", dynlib: LibName.}

    proc LowerBlit(src: PSurface; srcrect: PRect; dst: PSurface; dstrect: PRect): int {.
        cdecl, importc: "SDL_LowerBlit", dynlib: LibName.}

    proc FillRect(dst: PSurface; dstrect: PRect; color: int32): int {.cdecl,
        importc: "SDL_FillRect", dynlib: LibName.}

    proc DisplayFormat(surface: PSurface): PSurface {.cdecl,
        importc: "SDL_DisplayFormat", dynlib: LibName.}

    proc DisplayFormatAlpha(surface: PSurface): PSurface {.cdecl,
        importc: "SDL_DisplayFormatAlpha", dynlib: LibName.}

    proc CreateYUVOverlay(width: int; height: int; format: int32; display: PSurface): POverlay {.
        cdecl, importc: "SDL_CreateYUVOverlay", dynlib: LibName.}

    proc LockYUVOverlay(Overlay: POverlay): int {.cdecl,
        importc: "SDL_LockYUVOverlay", dynlib: LibName.}

    proc UnlockYUVOverlay(Overlay: POverlay) {.cdecl,
        importc: "SDL_UnlockYUVOverlay", dynlib: LibName.}

    proc DisplayYUVOverlay(Overlay: POverlay; dstrect: PRect): int {.cdecl,
        importc: "SDL_DisplayYUVOverlay", dynlib: LibName.}

    proc FreeYUVOverlay(Overlay: POverlay) {.cdecl, importc: "SDL_FreeYUVOverlay",
        dynlib: LibName.}

    proc GL_LoadLibrary(filename: cstring): int {.cdecl,
        importc: "SDL_GL_LoadLibrary", dynlib: LibName.}

    proc GL_GetProcAddress(procname: cstring): pointer {.cdecl,
        importc: "SDL_GL_GetProcAddress", dynlib: LibName.}

    proc GL_SetAttribute(attr: TGLAttr; value: int): int {.cdecl,
        importc: "SDL_GL_SetAttribute", dynlib: LibName.}

    proc GL_GetAttribute(attr: TGLAttr; value: var int): int {.cdecl,
        importc: "SDL_GL_GetAttribute", dynlib: LibName.}

    proc GL_SwapBuffers() {.cdecl, importc: "SDL_GL_SwapBuffers", dynlib: LibName.}

    proc GL_UpdateRects(numrects: int; rects: PRect) {.cdecl,
        importc: "SDL_GL_UpdateRects", dynlib: LibName.}

    proc GL_Lock() {.cdecl, importc: "SDL_GL_Lock", dynlib: LibName.}

    proc GL_Unlock() {.cdecl, importc: "SDL_GL_Unlock", dynlib: LibName.}

    proc WM_GetCaption(title: var cstring; icon: var cstring) {.cdecl,
        importc: "SDL_WM_GetCaption", dynlib: LibName.}

    proc WM_SetCaption(title: cstring; icon: cstring) {.cdecl,
        importc: "SDL_WM_SetCaption", dynlib: LibName.}

    proc WM_SetIcon(icon: PSurface; mask: Byte) {.cdecl, importc: "SDL_WM_SetIcon",
        dynlib: LibName.}

    proc WM_IconifyWindow(): int {.cdecl, importc: "SDL_WM_IconifyWindow",
                                   dynlib: LibName.}

    proc WM_ToggleFullScreen(surface: PSurface): int {.cdecl,
        importc: "SDL_WM_ToggleFullScreen", dynlib: LibName.}

    proc WM_GrabInput(mode: TGrabMode): TGrabMode {.cdecl,
        importc: "SDL_WM_GrabInput", dynlib: LibName.}

    proc GetMouseState(x: var int; y: var int): Byte {.cdecl,
        importc: "SDL_GetMouseState", dynlib: LibName.}

    proc GetRelativeMouseState(x: var int; y: var int): Byte {.cdecl,
        importc: "SDL_GetRelativeMouseState", dynlib: LibName.}

    proc WarpMouse(x, y: uint16) {.cdecl, importc: "SDL_WarpMouse", dynlib: LibName.}

    proc CreateCursor(data, mask: ptr Byte; w, h, hot_x, hot_y: int): PCursor {.
        cdecl, importc: "SDL_CreateCursor", dynlib: LibName.}

    proc SetCursor(cursor: PCursor) {.cdecl, importc: "SDL_SetCursor",
                                      dynlib: LibName.}

    proc GetCursor(): PCursor {.cdecl, importc: "SDL_GetCursor", dynlib: LibName.}

    proc FreeCursor(cursor: PCursor) {.cdecl, importc: "SDL_FreeCursor",
                                       dynlib: LibName.}

    proc ShowCursor(toggle: int): int {.cdecl, importc: "SDL_ShowCursor",
                                        dynlib: LibName.}

    proc EnableUNICODE(enable: int): int {.cdecl, importc: "SDL_EnableUNICODE",
                                           dynlib: LibName.}

    proc EnableKeyRepeat(delay: int; interval: int): int {.cdecl,
        importc: "SDL_EnableKeyRepeat", dynlib: LibName.}

    proc GetKeyRepeat(delay: PInteger; interval: PInteger) {.cdecl,
        importc: "SDL_GetKeyRepeat", dynlib: LibName.}

    proc GetKeyState(numkeys: pointer): ptr Byte {.cdecl,
        importc: "SDL_GetKeyState", dynlib: LibName.}

    proc GetModState(): TMod {.cdecl, importc: "SDL_GetModState", dynlib: LibName.}

    proc SetModState(modstate: TMod) {.cdecl, importc: "SDL_SetModState",
                                       dynlib: LibName.}

    proc GetKeyName(key: TKey): cstring {.cdecl, importc: "SDL_GetKeyName",
                                          dynlib: LibName.}

    proc GetAppState(): Byte {.cdecl, importc: "SDL_GetAppState", dynlib: LibName.}

    proc CreateMutex(): PMutex {.cdecl, importc: "SDL_CreateMutex", dynlib: LibName.}

    proc mutexP(mutex: PMutex): int {.cdecl, importc: "SDL_mutexP", dynlib: LibName.}

    proc mutexV(mutex: PMutex): int {.cdecl, importc: "SDL_mutexV", dynlib: LibName.}

    proc DestroyMutex(mutex: PMutex) {.cdecl, importc: "SDL_DestroyMutex",
                                       dynlib: LibName.}

    proc CreateSemaphore(initial_value: int32): PSem {.cdecl,
        importc: "SDL_CreateSemaphore", dynlib: LibName.}

    proc DestroySemaphore(sem: PSem) {.cdecl, importc: "SDL_DestroySemaphore",
                                       dynlib: LibName.}

    proc SemWait(sem: PSem): int {.cdecl, importc: "SDL_SemWait", dynlib: LibName.}

    proc SemTryWait(sem: PSem): int {.cdecl, importc: "SDL_SemTryWait",
                                      dynlib: LibName.}

    proc SemWaitTimeout(sem: PSem; ms: int32): int {.cdecl,
        importc: "SDL_SemWaitTimeout", dynlib: LibName.}

    proc SemPost(sem: PSem): int {.cdecl, importc: "SDL_SemPost", dynlib: LibName.}

    proc SemValue(sem: PSem): int32 {.cdecl, importc: "SDL_SemValue",
                                      dynlib: LibName.}

    proc CreateCond(): PCond {.cdecl, importc: "SDL_CreateCond", dynlib: LibName.}

    proc DestroyCond(cond: PCond) {.cdecl, importc: "SDL_DestroyCond",
                                    dynlib: LibName.}

    proc CondSignal(cond: PCond): int {.cdecl, importc: "SDL_CondSignal",
                                        dynlib: LibName.}

    proc CondBroadcast(cond: PCond): int {.cdecl, importc: "SDL_CondBroadcast",
                                           dynlib: LibName.}

    proc CondWait(cond: PCond; mut: PMutex): int {.cdecl, importc: "SDL_CondWait",
        dynlib: LibName.}

    proc CondWaitTimeout(cond: PCond; mut: PMutex; ms: int32): int {.cdecl,
        importc: "SDL_CondWaitTimeout", dynlib: LibName.}

    proc CreateThread(fn, data: pointer): PThread {.cdecl,
        importc: "SDL_CreateThread", dynlib: LibName.}

    proc ThreadID(): int32 {.cdecl, importc: "SDL_ThreadID", dynlib: LibName.}

    proc GetThreadID(thread: PThread): int32 {.cdecl, importc: "SDL_GetThreadID",
        dynlib: LibName.}

    proc WaitThread(thread: PThread; status: var int) {.cdecl,
        importc: "SDL_WaitThread", dynlib: LibName.}

    proc KillThread(thread: PThread) {.cdecl, importc: "SDL_KillThread",
                                       dynlib: LibName.}

    proc GetWMInfo(info: PSysWMinfo): int {.cdecl, importc: "SDL_GetWMInfo",
                                            dynlib: LibName.}

    proc LoadObject(sofile: cstring): pointer {.cdecl, importc: "SDL_LoadObject",
        dynlib: LibName.}

    proc LoadFunction(handle: pointer; name: cstring): pointer {.cdecl,
        importc: "SDL_LoadFunction", dynlib: LibName.}

    proc UnloadObject(handle: pointer) {.cdecl, importc: "SDL_UnloadObject",
                                         dynlib: LibName.}

    proc TableSize(table: cstring): int {.raises: [], tags: [].}

    proc OutOfMemory() {.raises: [], tags: [].}

    proc RWSeek(context: PRWops; offset: int; whence: int): int {.raises: [E_Base],
        tags: [TEffect].}

    proc RWTell(context: PRWops): int {.raises: [E_Base], tags: [TEffect].}

    proc RWRead(context: PRWops; theptr: pointer; size: int; n: int): int {.
        raises: [E_Base], tags: [TEffect].}

    proc RWWrite(context: PRWops; theptr: pointer; size: int; n: int): int {.
        raises: [E_Base], tags: [TEffect].}

    proc RWClose(context: PRWops): int {.raises: [E_Base], tags: [TEffect].}

    proc LoadWAV(filename: cstring; spec: PAudioSpec; audio_buf: ptr Byte;
                 audiolen: PUInt32): PAudioSpec {.raises: [], tags: [].}

    proc CDInDrive(status: TCDStatus): bool {.raises: [], tags: [].}

    proc FRAMES_TO_MSF(frames: int; M: var int; S: var int; F: var int) {.
        raises: [], tags: [].}

    proc MSF_TO_FRAMES(M: int; S: int; F: int): int {.raises: [], tags: [].}

    proc VERSION(X: var Tversion) {.raises: [], tags: [].}

    proc VERSIONNUM(X, Y, Z: int): int {.raises: [], tags: [].}

    proc COMPILEDVERSION(): int {.raises: [], tags: [].}

    proc VERSION_ATLEAST(X: int; Y: int; Z: int): bool {.raises: [], tags: [].}

    proc LoadBMP(filename: cstring): PSurface {.raises: [], tags: [].}

    proc SaveBMP(surface: PSurface; filename: cstring): int {.raises: [], tags: [].}

    proc BlitSurface(src: PSurface; srcrect: PRect; dst: PSurface; dstrect: PRect): int {.
        raises: [], tags: [].}

    proc AllocSurface(flags: int32; width, height, depth: int;
                      RMask, GMask, BMask, AMask: int32): PSurface {.raises: [],
        tags: [].}

    proc MustLock(Surface: PSurface): bool {.raises: [], tags: [].}

    proc LockMutex(mutex: PMutex): int {.raises: [], tags: [].}

    proc UnlockMutex(mutex: PMutex): int {.raises: [], tags: [].}

    proc BUTTON(Button: int): int {.raises: [], tags: [].}

    proc Swap32(D: int32): int32 {.raises: [], tags: [].}

    proc IsBitOn(value: int; bit: int8): bool {.raises: [], tags: [].}

    proc TurnBitOn(value: int; bit: int8): int {.raises: [], tags: [].}

    proc TurnBitOff(value: int; bit: int8): int {.raises: [], tags: [].}

Generated: 2013-05-21 09:55:05 UTC