AppSDL Code

The code of the appSDL unit of the SuperMaximo SDL AppEngine

///////////////////////////////////////////////////////////////////////////////
///                                                                         ///
///                  SUPERMAXIMO APP ENGINE: AppSDL Unit                    ///
///                  by Max Foster                                          ///
///                                                                         ///
///////////////////////////////////////////////////////////////////////////////
{
   Copyright (c) 2011 Max Foster

    Licensed under the Apache License, Version 2.0 (the'License'); you may not
    use this file except in compliance with the License, as described at
    http://www.apache.org/licenses/ and http://www.pp4s.co.uk/licenses/
}
{
This unit is part of the SuperMaximo App Engine(c). It initialises and closes SDL,
without needing to actually include the SDL unit itself in the main program code.
}
unit AppSDL;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, SDL;

const
  SDL_INIT_TIMER = $00000001;
  SDL_INIT_AUDIO = $00000010;
  SDL_INIT_VIDEO = $00000020;
  SDL_INIT_CDROM = $00000100;
  SDL_INIT_JOYSTICK = $00000200;
  SDL_INIT_NOPARACHUTE = $00100000;
  SDL_INIT_EVENTTHREAD = $01000000;
  SDL_INIT_EVERYTHING = $0000FFFF;

//Initialises everything from SDL with the specified flags shown in the constants section
procedure InitAppSDL(flags : UInt32 = SDL_INIT_NOPARACHUTE);

//Quits SDL
procedure QuitAppSDL;

//Delays for a set amount of time
procedure Wait(time : longint);

implementation

procedure InitAppSDL(flags : UInt32 = SDL_INIT_NOPARACHUTE);
begin
  if flags <> SDL_INIT_NOPARACHUTE then
    SDL_INIT(flags or SDL_INIT_NOPARACHUTE)
  else
    SDL_INIT(SDL_INIT_NOPARACHUTE);
end;

procedure QuitAppSDL;
begin
  SDL_QUIT;
end;

procedure Wait(time : longint);
begin
  SDL_DELAY(time);
end;

end.
Programming - a skill for life!

by Max Foster: L6 Age ~16