1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  10. with Allegro.Fixed_Point_Math;          use Allegro.Fixed_Point_Math; 
  11. with Allegro.Truecolor;                 use Allegro.Truecolor; 
  12.  
  13. -- Allegro 4.4.2 - Blitting and Sprites 
  14. package Allegro.Sprites is 
  15.  
  16.     -- Drawing modes for Draw_Sprite_Ex 
  17.     DRAW_SPRITE_NORMAL : constant Integer; 
  18.     DRAW_SPRITE_LIT    : constant Integer; 
  19.     DRAW_SPRITE_TRANS  : constant Integer; 
  20.  
  21.     -- Flipping modes for Draw_Sprite_Ex 
  22.     FLIP_DRAW_SPRITE_NO_FLIP : constant Integer; 
  23.     FLIP_DRAW_SPRITE_H_FLIP  : constant Integer; 
  24.     FLIP_DRAW_SPRITE_V_FLIP  : constant Integer; 
  25.     FLIP_DRAW_SPRITE_VH_FLIP : constant Integer; 
  26.  
  27.     ---------------------------------------------------------------------------- 
  28.  
  29.     procedure Blit( source, 
  30.                     dest     : not null A_Bitmap; 
  31.                     source_x, 
  32.                     source_y, 
  33.                     dest_x, 
  34.                     dest_y   : Integer; 
  35.                     width, 
  36.                     height   : Natural ); 
  37.  
  38.     procedure Draw_Character_Ex( bmp, 
  39.                                  sprite : not null A_Bitmap; 
  40.                                  x, y   : Integer; 
  41.                                  color, 
  42.                                  bg     : Color_Type ); 
  43.  
  44.     procedure Draw_Gouraud_Sprite( bmp, 
  45.                                    sprite         : not null A_Bitmap; 
  46.                                    x, y, 
  47.                                    c1, c2, c3, c4 : Color_Type ); 
  48.  
  49.     procedure Draw_Lit_Sprite( bmp, 
  50.                                sprite : not null A_Bitmap; 
  51.                                x, y   : Integer; 
  52.                                color  : Color_Type ); 
  53.  
  54.     procedure Draw_Sprite( bmp, sprite : not null A_Bitmap; x, y : Integer ); 
  55.  
  56.     procedure Draw_Sprite_Ex( bmp, 
  57.                               sprite : not null A_Bitmap; 
  58.                               x, y   : Integer; 
  59.                               mode   : Integer; 
  60.                               flip   : Integer ); 
  61.  
  62.     procedure Draw_Sprite_H_Flip( bmp, sprite : not null A_Bitmap; x, y : Integer ); 
  63.  
  64.     procedure Draw_Sprite_V_Flip( bmp, sprite : not null A_Bitmap; x, y : Integer ); 
  65.  
  66.     procedure Draw_Sprite_VH_Flip( bmp, sprite : not null A_Bitmap; x, y : Integer ); 
  67.  
  68.     procedure Draw_Trans_Sprite( bmp, sprite : not null A_Bitmap; x, y : Integer ); 
  69.  
  70.     procedure Masked_Blit( source, 
  71.                            dest     : not null A_Bitmap; 
  72.                            source_x, 
  73.                            source_y, 
  74.                            dest_x, 
  75.                            dest_y   : Integer; 
  76.                            width, 
  77.                            height   : Natural ); 
  78.  
  79.     procedure Masked_Stretch_Blit( source, 
  80.                                    dest     : not null A_Bitmap; 
  81.                                    source_x, 
  82.                                    source_y : Integer; 
  83.                                    source_w, 
  84.                                    source_h : Natural; 
  85.                                    dest_x, 
  86.                                    dest_y   : Integer; 
  87.                                    dest_w, 
  88.                                    dest_h   : Natural ); 
  89.  
  90.     procedure Pivot_Scaled_Sprite( bmp, 
  91.                                    sprite : not null A_Bitmap; 
  92.                                    x, y, 
  93.                                    cx, cy : Integer; 
  94.                                    angle, 
  95.                                    scale  : Fixed ); 
  96.  
  97.     procedure Pivot_Scaled_Sprite_Lit( bmp, 
  98.                                        sprite : not null A_Bitmap; 
  99.                                        x, y, 
  100.                                        cx, cy : Integer; 
  101.                                        angle, 
  102.                                        scale  : Fixed; 
  103.                                        color  : Color_Type ); 
  104.  
  105.     procedure Pivot_Scaled_Sprite_Trans( bmp, 
  106.                                          sprite : not null A_Bitmap; 
  107.                                          x, y, 
  108.                                          cx, cy : Integer; 
  109.                                          angle, 
  110.                                          scale  : Fixed ); 
  111.  
  112.     procedure Pivot_Scaled_Sprite_V_Flip( bmp, 
  113.                                           sprite : not null A_Bitmap; 
  114.                                           x, y, 
  115.                                           cx, cy : Integer; 
  116.                                           angle, 
  117.                                           scale  : Fixed ); 
  118.  
  119.     procedure Pivot_Scaled_Sprite_V_Flip_Lit( bmp, 
  120.                                               sprite : not null A_Bitmap; 
  121.                                               x, y, 
  122.                                               cx, cy : Integer; 
  123.                                               angle, 
  124.                                               scale  : Fixed; 
  125.                                               color  : Color_Type ); 
  126.  
  127.     procedure Pivot_Scaled_Sprite_V_Flip_Trans( bmp, 
  128.                                                 sprite : not null A_Bitmap; 
  129.                                                 x, y, 
  130.                                                 cx, cy : Integer; 
  131.                                                 angle, 
  132.                                                 scale  : Fixed ); 
  133.  
  134.     procedure Pivot_Sprite( bmp, 
  135.                             sprite : not null A_Bitmap; 
  136.                             x, y, 
  137.                             cx, cy : Integer; 
  138.                             angle  : Fixed ); 
  139.  
  140.     procedure Pivot_Sprite_Lit( bmp, 
  141.                                 sprite : not null A_Bitmap; 
  142.                                 x, y, 
  143.                                 cx, cy : Integer; 
  144.                                 angle  : Fixed; 
  145.                                 color  : Color_Type ); 
  146.  
  147.     procedure Pivot_Sprite_Trans( bmp, 
  148.                                   sprite : not null A_Bitmap; 
  149.                                   x, y, 
  150.                                   cx, cy : Integer; 
  151.                                   angle  : Fixed ); 
  152.  
  153.     procedure Pivot_Sprite_V_Flip( bmp, 
  154.                                    sprite : not null A_Bitmap; 
  155.                                    x, y, 
  156.                                    cx, cy : Integer; 
  157.                                    angle  : Fixed ); 
  158.  
  159.     procedure Pivot_Sprite_V_Flip_Lit( bmp, 
  160.                                        sprite : not null A_Bitmap; 
  161.                                        x, y, 
  162.                                        cx, cy : Integer; 
  163.                                        angle  : Fixed; 
  164.                                        color  : Color_Type ); 
  165.  
  166.     procedure Pivot_Sprite_V_Flip_Trans( bmp, 
  167.                                          sprite : not null A_Bitmap; 
  168.                                          x, y, 
  169.                                          cx, cy : Integer; 
  170.                                          angle  : Fixed ); 
  171.  
  172.     procedure Rotate_Scaled_Sprite( bmp, 
  173.                                     sprite : not null A_Bitmap; 
  174.                                     x, y   : Integer; 
  175.                                     angle, 
  176.                                     scale  : Fixed ); 
  177.  
  178.     procedure Rotate_Scaled_Sprite_Lit( bmp, 
  179.                                         sprite : not null A_Bitmap; 
  180.                                         x, y   : Integer; 
  181.                                         angle, 
  182.                                         scale  : Fixed; 
  183.                                         color  : Color_Type ); 
  184.  
  185.     procedure Rotate_Scaled_Sprite_Trans( bmp, 
  186.                                           sprite : not null A_Bitmap; 
  187.                                           x, y   : Integer; 
  188.                                           angle, 
  189.                                           scale  : Fixed ); 
  190.  
  191.     procedure Rotate_Scaled_Sprite_V_Flip( bmp, 
  192.                                            sprite : not null A_Bitmap; 
  193.                                            x, y   : Integer; 
  194.                                            angle, 
  195.                                            scale  : Fixed ); 
  196.  
  197.     procedure Rotate_Scaled_Sprite_V_Flip_Lit( bmp, 
  198.                                                sprite : not null A_Bitmap; 
  199.                                                x, y   : Integer; 
  200.                                                angle, 
  201.                                                scale  : Fixed; 
  202.                                                color  : Color_Type ); 
  203.  
  204.     procedure Rotate_Scaled_Sprite_V_Flip_Trans( bmp, 
  205.                                                  sprite : not null A_Bitmap; 
  206.                                                  x, y   : Integer; 
  207.                                                  angle, 
  208.                                                  scale  : Fixed ); 
  209.  
  210.     procedure Rotate_Sprite( bmp, 
  211.                              sprite : not null A_Bitmap; 
  212.                              x, y   : Integer; 
  213.                              angle  : Fixed ); 
  214.  
  215.     procedure Rotate_Sprite_Lit( bmp, 
  216.                                  sprite : not null A_Bitmap; 
  217.                                  x, y   : Integer; 
  218.                                  angle  : Fixed; 
  219.                                  color  : Color_Type ); 
  220.  
  221.     procedure Rotate_Sprite_Trans( bmp, 
  222.                                    sprite : not null A_Bitmap; 
  223.                                    x, y   : Integer; 
  224.                                    angle  : Fixed ); 
  225.  
  226.     procedure Rotate_Sprite_V_Flip( bmp, 
  227.                                     sprite : not null A_Bitmap; 
  228.                                     x, y   : Integer; 
  229.                                     angle  : Fixed ); 
  230.  
  231.     procedure Rotate_Sprite_V_Flip_Lit( bmp, 
  232.                                         sprite : not null A_Bitmap; 
  233.                                         x, y   : Integer; 
  234.                                         angle  : Fixed; 
  235.                                         color  : Color_Type ); 
  236.  
  237.     procedure Rotate_Sprite_V_Flip_Trans( bmp, 
  238.                                           sprite : not null A_Bitmap; 
  239.                                           x, y   : Integer; 
  240.                                           angle  : Fixed ); 
  241.  
  242.     procedure Stretch_Blit( source, 
  243.                             dest          : not null A_Bitmap; 
  244.                             source_x, 
  245.                             source_y      : Integer; 
  246.                             source_width, 
  247.                             source_height : Natural; 
  248.                             dest_x, 
  249.                             dest_y        : Integer; 
  250.                             dest_width, 
  251.                             dest_height   : Natural ); 
  252.  
  253.     procedure Stretch_Sprite( bmp, 
  254.                               sprite : not null A_Bitmap; 
  255.                               x, y   : Integer; 
  256.                               w, h   : Natural ); 
  257.  
  258. private 
  259.  
  260.     DRAW_SPRITE_NORMAL : constant Integer := 0; 
  261.     DRAW_SPRITE_LIT    : constant Integer := 1; 
  262.     DRAW_SPRITE_TRANS  : constant Integer := 2; 
  263.  
  264.     FLIP_DRAW_SPRITE_NO_FLIP : constant Integer := 2#00#; 
  265.     FLIP_DRAW_SPRITE_H_FLIP  : constant Integer := 2#01#; 
  266.     FLIP_DRAW_SPRITE_V_FLIP  : constant Integer := 2#10#; 
  267.     FLIP_DRAW_SPRITE_VH_FLIP : constant Integer := 2#11#; 
  268.  
  269.     ---------------------------------------------------------------------------- 
  270.  
  271.     pragma Import( C, Blit, "blit" ); 
  272.     pragma Import( C, Draw_Character_Ex, "draw_character_ex" ); 
  273.     pragma Import( C, Draw_Gouraud_Sprite, "draw_gouraud_sprite" ); 
  274.     pragma Import( C, Draw_Lit_Sprite, "draw_lit_sprite" ); 
  275.     pragma Import( C, Draw_Sprite, "draw_sprite" ); 
  276.     pragma Import( C, Draw_Sprite_Ex, "draw_sprite_ex" ); 
  277.     pragma Import( C, Draw_Sprite_H_Flip, "draw_sprite_h_flip" ); 
  278.     pragma Import( C, Draw_Sprite_V_Flip, "draw_sprite_v_flip" ); 
  279.     pragma Import( C, Draw_Sprite_VH_Flip, "draw_sprite_vh_flip" ); 
  280.     pragma Import( C, Draw_Trans_Sprite, "draw_trans_sprite" ); 
  281.     pragma Import( C, Masked_Blit, "masked_blit" ); 
  282.     pragma Import( C, Masked_Stretch_Blit, "masked_stretch_blit" ); 
  283.     pragma Import( C, Pivot_Scaled_Sprite, "pivot_scaled_sprite" ); 
  284.     pragma Import( C, Pivot_Scaled_Sprite_Lit, "pivot_scaled_sprite_lit" ); 
  285.     pragma Import( C, Pivot_Scaled_Sprite_Trans, "pivot_scaled_sprite_trans" ); 
  286.     pragma Import( C, Pivot_Scaled_Sprite_V_Flip, "pivot_scaled_sprite_v_flip" ); 
  287.     pragma Import( C, Pivot_Scaled_Sprite_V_Flip_Lit, "pivot_scaled_sprite_v_flip_lit" ); 
  288.     pragma Import( C, Pivot_Scaled_Sprite_V_Flip_Trans, "pivot_scaled_sprite_v_flip_trans" ); 
  289.     pragma Import( C, Pivot_Sprite, "pivot_sprite" ); 
  290.     pragma Import( C, Pivot_Sprite_Lit, "pivot_sprite_lit" ); 
  291.     pragma Import( C, Pivot_Sprite_Trans, "pivot_sprite_trans" ); 
  292.     pragma Import( C, Pivot_Sprite_V_Flip, "pivot_sprite_v_flip" ); 
  293.     pragma Import( C, Pivot_Sprite_V_Flip_Lit, "pivot_sprite_v_flip_lit" ); 
  294.     pragma Import( C, Pivot_Sprite_V_Flip_Trans, "pivot_sprite_v_flip_trans" ); 
  295.     pragma Import( C, Rotate_Scaled_Sprite, "rotate_scaled_sprite" ); 
  296.     pragma Import( C, Rotate_Scaled_Sprite_Lit, "rotate_scaled_sprite_lit" ); 
  297.     pragma Import( C, Rotate_Scaled_Sprite_Trans, "rotate_scaled_sprite_trans" ); 
  298.     pragma Import( C, Rotate_Scaled_Sprite_V_Flip, "rotate_scaled_sprite_v_flip" ); 
  299.     pragma Import( C, Rotate_Scaled_Sprite_V_Flip_Lit, "rotate_scaled_sprite_v_flip_lit" ); 
  300.     pragma Import( C, Rotate_Scaled_Sprite_V_Flip_Trans, "rotate_scaled_sprite_v_flip_trans" ); 
  301.     pragma Import( C, Rotate_Sprite, "rotate_sprite" ); 
  302.     pragma Import( C, Rotate_Sprite_Lit, "rotate_sprite_lit" ); 
  303.     pragma Import( C, Rotate_Sprite_Trans, "rotate_sprite_trans" ); 
  304.     pragma Import( C, Rotate_Sprite_V_Flip, "rotate_sprite_v_flip" ); 
  305.     pragma Import( C, Rotate_Sprite_V_Flip_Lit, "rotate_sprite_v_flip_lit" ); 
  306.     pragma Import( C, Rotate_Sprite_V_Flip_Trans, "rotate_sprite_v_flip_trans" ); 
  307.     pragma Import( C, Stretch_Blit, "stretch_blit" ); 
  308.     pragma Import( C, Stretch_Sprite, "stretch_sprite" ); 
  309.  
  310. end Allegro.Sprites;