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.Truecolor;                 use Allegro.Truecolor; 
  10.  
  11. -- Allegro 4.4.2 - Bitmap objects 
  12. package Allegro.Bitmaps is 
  13.  
  14.     type Gfx_Vtable is private; 
  15.     type A_Gfx_Vtable is access all Gfx_Vtable; 
  16.  
  17.     type Bitmap is private; 
  18.     type A_Bitmap is access all Bitmap; 
  19.     pragma No_Strict_Aliasing( A_Bitmap ); 
  20.  
  21.     ---------------------------------------------------------------------------- 
  22.  
  23.     procedure Acquire_Bitmap( bmp : not null A_Bitmap ); 
  24.  
  25.     procedure Acquire_Screen; 
  26.  
  27.     procedure Add_Clip_Rect( bmp : not null A_Bitmap; x1, y1, x2, y2 : Integer ); 
  28.  
  29.     function Bitmap_Color_Depth( bmp : not null A_Bitmap ) return Integer; 
  30.  
  31.     function Bitmap_Mask_Color( bmp : not null A_Bitmap ) return Color_Type; 
  32.  
  33.     function Create_Bitmap( width, height : Positive ) return A_Bitmap; 
  34.  
  35.     function Create_Bitmap_Ex( color_depth, width, height : Positive ) return A_Bitmap; 
  36.  
  37.     function Create_Sub_Bitmap( parent : not null A_Bitmap; 
  38.                                 x, y   : Integer; 
  39.                                 width, 
  40.                                 height : Positive ) return A_Bitmap; 
  41.  
  42.     function Create_System_Bitmap( width, height : Positive ) return A_Bitmap; 
  43.  
  44.     function Create_Video_Bitmap( width, height : Positive ) return A_Bitmap; 
  45.  
  46.     procedure Destroy_Bitmap( bmp : in out A_Bitmap ); 
  47.  
  48.     procedure Get_Clip_Rect( bmp    : not null A_Bitmap; 
  49.                              x1, y1, 
  50.                              x2, y2 : out Integer ); 
  51.  
  52.     function Get_Clip_State( bmp : not null A_Bitmap ) return Integer; 
  53.  
  54.     function Get_Dat( bmp : A_Bitmap ) return Address; 
  55.  
  56.     function Get_Height( bmp : A_Bitmap ) return Integer; 
  57.  
  58.     function Get_Screen return A_Bitmap; 
  59.  
  60.     function Get_Screen_H return Integer; 
  61.  
  62.     function Get_Screen_W return Integer; 
  63.  
  64.     function Get_Virtual_H return Integer; 
  65.  
  66.     function Get_Virtual_W return Integer; 
  67.  
  68.     function Get_Width( bmp : A_Bitmap ) return Integer; 
  69.  
  70.     function Is_Inside_Bitmap( bmp : not null A_Bitmap; x, y, clip : Integer ) return Integer; 
  71.  
  72.     function Is_Linear_Bitmap( bmp : A_Bitmap ) return Integer; 
  73.  
  74.     function Is_Memory_Bitmap( bmp : A_Bitmap ) return Integer; 
  75.  
  76.     function Is_Planar_Bitmap( bmp : A_Bitmap ) return Integer; 
  77.  
  78.     function Is_Same_Bitmap( bmp1, bmp2 : A_Bitmap ) return Integer; 
  79.  
  80.     function Is_Screen_Bitmap( bmp : A_Bitmap ) return Integer; 
  81.  
  82.     function Is_Sub_Bitmap( bmp : A_Bitmap ) return Integer; 
  83.  
  84.     function Is_System_Bitmap( bmp : A_Bitmap ) return Integer; 
  85.  
  86.     function Is_Video_Bitmap( bmp : A_Bitmap ) return Integer; 
  87.  
  88.     procedure Lock_Bitmap( bmp : not null A_Bitmap ); 
  89.  
  90.     procedure Release_Bitmap( bmp : not null A_Bitmap ); 
  91.  
  92.     procedure Release_Screen; 
  93.  
  94.     procedure Set_Clip_Rect( bmp : not null A_Bitmap; x1, y1, x2, y2 : Integer ); 
  95.  
  96.     procedure Set_Clip_State( bmp : not null A_Bitmap; state : Integer ); 
  97.  
  98. private 
  99.  
  100.     type Gfx_Vtable is     -- functions for drawing onto bitmaps 
  101.         record 
  102.             color_depth                : Integer; 
  103.             mask_color                 : Integer; 
  104.             unwrite_bank               : Address; 
  105.             set_clip                   : Address; 
  106.             acquire                    : Address; 
  107.             release                    : Address; 
  108.             create_sub_bitmap          : Address; 
  109.             created_sub_bitmap         : Address; 
  110.             getpixel                   : Address; 
  111.             putpixel                   : Address; 
  112.             vline                      : Address; 
  113.             hline                      : Address; 
  114.             hfill                      : Address; 
  115.             line                       : Address; 
  116.             fastline                   : Address; 
  117.             rectfill                   : Address; 
  118.             triangle                   : Address; 
  119.             draw_sprite                : Address; 
  120.             draw_256_sprite            : Address; 
  121.             draw_sprite_v_flip         : Address; 
  122.             draw_sprite_h_flip         : Address; 
  123.             draw_sprite_vh_flip        : Address; 
  124.             draw_trans_sprite          : Address; 
  125.             draw_trans_rgba_sprite     : Address; 
  126.             draw_lit_sprite            : Address; 
  127.             draw_rle_sprite            : Address; 
  128.             draw_trans_rle_sprite      : Address; 
  129.             draw_trans_rgba_rle_sprite : Address; 
  130.             draw_lit_rle_sprite        : Address; 
  131.             draw_character             : Address; 
  132.             draw_glyph                 : Address; 
  133.             blit_from_memory           : Address; 
  134.             blit_to_memory             : Address; 
  135.             blit_from_system           : Address; 
  136.             blit_to_system             : Address; 
  137.             blit_to_self               : Address; 
  138.             blit_to_self_forward       : Address; 
  139.             blit_to_self_backward      : Address; 
  140.             blit_between_formats       : Address; 
  141.             masked_blit                : Address; 
  142.             clear_to_color             : Address; 
  143.             pivot_scaled_sprite_flip   : Address; 
  144.             do_stretch_blit            : Address; 
  145.             draw_gouraud_sprite        : Address; 
  146.             draw_sprite_end            : Address; 
  147.             blit_end                   : Address; 
  148.             polygon                    : Address; 
  149.             rect                       : Address; 
  150.             circle                     : Address; 
  151.             circlefill                 : Address; 
  152.             elipse                     : Address; 
  153.             elipsefill                 : Address; 
  154.             arc                        : Address; 
  155.             spline                     : Address; 
  156.             floodfill                  : Address; 
  157.             polygon3d                  : Address; 
  158.             polygon3d_f                : Address; 
  159.             triangle3d                 : Address; 
  160.             triangle3d_f               : Address; 
  161.             quad3d                     : Address; 
  162.             quad3d_f                   : Address; 
  163.             draw_sprite_ex             : Address; 
  164.         end record; 
  165.     pragma Convention( C, Gfx_Vtable ); 
  166.  
  167.     type Bitmap is 
  168.         record 
  169.             w, h       : Integer; 
  170.             clip       : Integer; 
  171.             cl, cr, 
  172.             ct, cb     : Integer; 
  173.             vtable     : A_Gfx_Vtable; 
  174.             write_bank : Address; 
  175.             read_bank  : Address; 
  176.             dat        : Address; 
  177.             id         : Unsigned_64; 
  178.             extra      : Address; 
  179.             x_ofs, 
  180.             y_ofs      : Integer; 
  181.             seg        : Integer; 
  182.             line       : Address; 
  183.             --     line  : AL_ucmatrix(0 .. 479,0 .. 619);   -- 620 x 480 
  184.         end record; 
  185.     pragma Convention( C, Bitmap ); 
  186.  
  187.     ---------------------------------------------------------------------------- 
  188.  
  189.     pragma Import( C, Acquire_Bitmap, "acquire_bitmap" ); 
  190.     pragma Import( C, Acquire_Screen, "acquire_screen" ); 
  191.     pragma Import( C, Add_Clip_Rect, "add_clip_rect" ); 
  192.     pragma Import( C, Bitmap_Color_Depth, "bitmap_color_depth" ); 
  193.     pragma Import( C, Bitmap_Mask_Color, "bitmap_mask_color" ); 
  194.     pragma Import( C, Create_Bitmap, "create_bitmap" ); 
  195.     pragma Import( C, Create_Bitmap_Ex, "create_bitmap_ex" ); 
  196.     pragma Import( C, Create_Sub_Bitmap, "create_sub_bitmap" ); 
  197.     pragma Import( C, Create_System_Bitmap, "create_systsem_bitmap" ); 
  198.     pragma Import( C, Create_Video_Bitmap, "create_video_bitmap" ); 
  199.     pragma Import( C, Get_Clip_Rect, "get_clip_rect" ); 
  200.     pragma Import( C, Get_Clip_State, "get_clip_state" ); 
  201.     pragma Import( C, Get_Screen, "get_screen" ); 
  202.     pragma Import( C, Get_Screen_H, "get_screen_h" ); 
  203.     pragma Import( C, Get_Screen_W, "get_screen_w" ); 
  204.     pragma Import( C, Get_Virtual_H, "get_virtual_h" ); 
  205.     pragma Import( C, Get_Virtual_W, "get_virtual_w" ); 
  206.     pragma Import( C, Is_Inside_Bitmap, "is_inside_bitmap" ); 
  207.     pragma Import( C, Is_Linear_Bitmap, "is_linear_bitmap" ); 
  208.     pragma Import( C, Is_Memory_Bitmap, "is_memory_bitmap" ); 
  209.     pragma Import( C, Is_Planar_Bitmap, "is_planar_bitmap" ); 
  210.     pragma Import( C, Is_Same_Bitmap, "is_same_bitmap" ); 
  211.     pragma Import( C, Is_Screen_Bitmap, "is_screen_bitmap" ); 
  212.     pragma Import( C, Is_Sub_Bitmap, "is_sub_bitmap" ); 
  213.     pragma Import( C, Is_System_Bitmap, "is_system_bitmap" ); 
  214.     pragma Import( C, Is_Video_Bitmap, "is_video_bitmap" ); 
  215.     pragma Import( C, Lock_Bitmap, "lock_bitmap" ); 
  216.     pragma Import( C, Release_Bitmap, "release_bitmap" ); 
  217.     pragma Import( C, Release_Screen, "release_screen" ); 
  218.     pragma Import( C, Set_Clip_Rect, "set_clip_rect" ); 
  219.     pragma Import( C, Set_Clip_State, "set_clip_state" ); 
  220.  
  221. end Allegro.Bitmaps;