{  DEMO PROGRAM MADE BY MATTHIAS MOLSKI, April 2008
   VISIT: http://www.fp.sdl.de.vu/  }

PROGRAM chap3;
USES SDL, CRT;
VAR
screen,picture:pSDL_SURFACE;
source_rect,destination_rect:pSDL_RECT;

BEGIN
SDL_INIT(SDL_INIT_VIDEO);
screen:=SDL_SETVIDEOMODE(200,200,32,SDL_SWSURFACE);
IF screen=NIL THEN HALT;

picture:=SDL_LOADBMP('C:\FPC\2.0.4\bin\i386-win32\test\fpsdl.bmp');
IF picture=NIL THEN HALT;

NEW(source_rect);
source_rect^.x:=0;
source_rect^.y:=0;
source_rect^.w:=200;
source_rect^.h:=200;
NEW(destination_rect);
destination_rect^.x:=0;
destination_rect^.y:=0;
destination_rect^.w:=200;
destination_rect^.h:=200;

REPEAT
  SDL_BLITSURFACE(picture,source_rect,screen,destination_rect);
  SDL_FLIP(screen);
  DEC(source_rect^.w);
  DEC(source_rect^.h);
  INC(destination_rect^.x);
  INC(destination_rect^.y);
  DEC(destination_rect^.w);
  DEC(destination_rect^.h);
  SDL_DELAY(30);
  IF source_rect^.w=1 THEN
  BEGIN
    source_rect^.x:=0;
    source_rect^.y:=0;
    source_rect^.w:=200;
    source_rect^.h:=200;
    destination_rect^.x:=0;
    destination_rect^.y:=0;
    destination_rect^.w:=200;
    destination_rect^.h:=200;
  END;
UNTIL keypressed;

SDL_FREESURFACE(picture);
SDL_FREESURFACE(screen);

DISPOSE(source_rect);
DISPOSE(destination_rect);

SDL_QUIT;
END.

