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_Ids; 
  11. pragma Warnings( Off, Allegro_Ids ); 
  12.  
  13. pragma Elaborate_All( Allegro_Ids ); 
  14.  
  15. -- Allegro 4.4.2 - Graphics modes 
  16. package Allegro.Graphics is 
  17.  
  18.     type Gfx_Mode is private; 
  19.     type A_Gfx_Mode is access all Gfx_Mode; 
  20.  
  21.     type Gfx_Mode_List is private; 
  22.     type A_Gfx_Mode_List is access all Gfx_Mode_List; 
  23.  
  24.     type Gfx_Detect_Type is private; 
  25.  
  26.     subtype Gfx_Capability is Unsigned_32; 
  27.  
  28.     type Switch_Mode is private; 
  29.     type Switch_Dir is private; 
  30.  
  31.     type A_Switch_Callback is 
  32.         access procedure; 
  33.  
  34.     ---------------------------------------------------------------------------- 
  35.  
  36.     GFX_AUTODETECT            : constant Gfx_Detect_Type; 
  37.     GFX_AUTODETECT_FULLSCREEN : constant Gfx_Detect_Type; 
  38.     GFX_AUTODETECT_WINDOWED   : constant Gfx_Detect_Type; 
  39.     GFX_TEXT                  : constant Gfx_Detect_Type; 
  40.     GFX_SAFE                  : constant Gfx_Detect_Type; 
  41.     GFX_NONE                  : constant Gfx_Detect_Type; 
  42.  
  43.     GFX_CAN_SCROLL             : constant Gfx_Capability; 
  44.     GFX_CAN_TRIPLE_BUFFER      : constant Gfx_Capability; 
  45.     GFX_HW_CURSOR              : constant Gfx_Capability; 
  46.     GFX_HW_HLINE               : constant Gfx_Capability; 
  47.     GFX_HW_HLINE_XOR           : constant Gfx_Capability; 
  48.     GFX_HW_HLINE_SOLID_PATTERN : constant Gfx_Capability; 
  49.     GFX_HW_HLINE_COPY_PATTERN  : constant Gfx_Capability; 
  50.     GFX_HW_FILL                : constant Gfx_Capability; 
  51.     GFX_HW_FILL_XOR            : constant Gfx_Capability; 
  52.     GFX_HW_FILL_SOLID_PATTERN  : constant Gfx_Capability; 
  53.     GFX_HW_FILL_COPY_PATTERN   : constant Gfx_Capability; 
  54.     GFX_HW_LINE                : constant Gfx_Capability; 
  55.     GFX_HW_LINE_XOR            : constant Gfx_Capability; 
  56.     GFX_HW_TRIANGLE            : constant Gfx_Capability; 
  57.     GFX_HW_TRIANGLE_XOR        : constant Gfx_Capability; 
  58.     GFX_HW_TEXTOUT_FIXED       : constant Gfx_Capability; 
  59.     GFX_HW_VRAM_BLIT           : constant Gfx_Capability; 
  60.     GFX_HW_VRAM_BLIT_MASKED    : constant Gfx_Capability; 
  61.     GFX_HW_MEM_BLIT            : constant Gfx_Capability; 
  62.     GFX_HW_MEM_BLIT_MASKED     : constant Gfx_Capability; 
  63.  
  64.     SWITCH_NONE        : constant Switch_Mode; 
  65.     SWITCH_PAUSE       : constant Switch_Mode; 
  66.     SWITCH_AMNESIA     : constant Switch_Mode; 
  67.     SWITCH_BACKGROUND  : constant Switch_Mode; 
  68.     SWITCH_BACKAMNESIA : constant Switch_Mode; 
  69.  
  70.     SWITCH_IN  : constant Switch_Dir; 
  71.     SWITCH_OUT : constant Switch_Dir; 
  72.  
  73.     ---------------------------------------------------------------------------- 
  74.  
  75.     procedure Destroy_Gfx_Mode_List( mode_list : in out A_Gfx_Mode_List ); 
  76.  
  77.     function Enable_Triple_Buffer return Integer; 
  78.  
  79.     function Get_Color_Depth return Natural; 
  80.  
  81.     function Get_Display_Switch_Mode return Switch_Mode; 
  82.  
  83.     function Get_Gfx_Mode return Gfx_Detect_Type; 
  84.  
  85.     function Get_Gfx_Mode_List( card : Integer ) return A_Gfx_Mode_List; 
  86.  
  87.     function Get_Refresh_Rate return Natural; 
  88.  
  89.     function Gfx_Capabilities return Unsigned_32; 
  90.  
  91.     function Is_Windowed_Mode return Boolean; 
  92.  
  93.     function Poll_Scroll return Integer; 
  94.  
  95.     procedure Remove_Display_Switch_Callback( cb : not null A_Switch_Callback ); 
  96.  
  97.     procedure Request_Refresh_Rate( rate : Natural ); 
  98.  
  99.     function Request_Scroll( x, y : Integer ) return Integer; 
  100.  
  101.     function Request_Video_Bitmap( bmp : not null A_Bitmap ) return Integer; 
  102.  
  103.     function Scroll_Screen( x, y : Integer ) return Integer; 
  104.  
  105.     procedure Set_Color_Depth( depth : Natural ); 
  106.  
  107.     function Set_Display_Switch_Callback( dir : Switch_Dir; 
  108.                                           cb  : A_Switch_Callback 
  109.                                         ) return Integer; 
  110.  
  111.     function Set_Display_Switch_Mode( mode : Switch_Mode ) return Integer; 
  112.  
  113.     function Set_Gfx_Mode( card     : Gfx_Detect_Type; 
  114.                            w, h, 
  115.                            v_w, v_h : Natural ) return Integer; 
  116.  
  117.     function Show_Video_Bitmap( bmp : not null A_Bitmap ) return Integer; 
  118.  
  119.     procedure Vsync; 
  120.  
  121. private 
  122.  
  123.     type Gfx_Mode is 
  124.         record 
  125.             width  : Integer; 
  126.             height : Integer; 
  127.             bpp    : Integer; 
  128.         end record; 
  129.     pragma Convention( C, Gfx_Mode ); 
  130.  
  131.     type Gfx_Mode_List is 
  132.         record 
  133.             num_modes : Integer; 
  134.             mode      : A_Gfx_Mode; 
  135.         end record; 
  136.     pragma Convention( C, Gfx_Mode_List ); 
  137.  
  138.     type Gfx_Detect_Type is new AL_ID; 
  139.  
  140.     type Switch_Mode is new Integer; 
  141.     type Switch_Dir is new Integer; 
  142.  
  143.     ---------------------------------------------------------------------------- 
  144.  
  145.     GFX_AUTODETECT            : constant Gfx_Detect_Type := To_AL_ID(0); 
  146.     GFX_AUTODETECT_FULLSCREEN : constant Gfx_Detect_Type := To_AL_ID(1); 
  147.     GFX_AUTODETECT_WINDOWED   : constant Gfx_Detect_Type := To_AL_ID(2); 
  148.     GFX_TEXT                  : constant Gfx_Detect_Type := To_AL_ID(-1); 
  149.     GFX_SAFE                  : constant Gfx_Detect_Type := To_AL_ID('S','A','F','E'); 
  150.     GFX_NONE                  : constant Gfx_Detect_Type := To_AL_ID('N','O','N','E'); 
  151.  
  152.     GFX_CAN_SCROLL             : constant Gfx_Capability := 16#00000001#; 
  153.     GFX_CAN_TRIPLE_BUFFER      : constant Gfx_Capability := 16#00000002#; 
  154.     GFX_HW_CURSOR              : constant Gfx_Capability := 16#00000004#; 
  155.     GFX_HW_HLINE               : constant Gfx_Capability := 16#00000008#; 
  156.     GFX_HW_HLINE_XOR           : constant Gfx_Capability := 16#00000010#; 
  157.     GFX_HW_HLINE_SOLID_PATTERN : constant Gfx_Capability := 16#00000020#; 
  158.     GFX_HW_HLINE_COPY_PATTERN  : constant Gfx_Capability := 16#00000040#; 
  159.     GFX_HW_FILL                : constant Gfx_Capability := 16#00000080#; 
  160.     GFX_HW_FILL_XOR            : constant Gfx_Capability := 16#00000100#; 
  161.     GFX_HW_FILL_SOLID_PATTERN  : constant Gfx_Capability := 16#00000200#; 
  162.     GFX_HW_FILL_COPY_PATTERN   : constant Gfx_Capability := 16#00000400#; 
  163.     GFX_HW_LINE                : constant Gfx_Capability := 16#00000800#; 
  164.     GFX_HW_LINE_XOR            : constant Gfx_Capability := 16#00001000#; 
  165.     GFX_HW_TRIANGLE            : constant Gfx_Capability := 16#00002000#; 
  166.     GFX_HW_TRIANGLE_XOR        : constant Gfx_Capability := 16#00004000#; 
  167.     GFX_HW_TEXTOUT_FIXED       : constant Gfx_Capability := 16#00008000#; 
  168.     GFX_HW_VRAM_BLIT           : constant Gfx_Capability := 16#00010000#; 
  169.     GFX_HW_VRAM_BLIT_MASKED    : constant Gfx_Capability := 16#00020000#; 
  170.     GFX_HW_MEM_BLIT            : constant Gfx_Capability := 16#00040000#; 
  171.     GFX_HW_MEM_BLIT_MASKED     : constant Gfx_Capability := 16#00080000#; 
  172.  
  173.     SWITCH_NONE        : constant Switch_Mode := 0; 
  174.     SWITCH_PAUSE       : constant Switch_Mode := 1; 
  175.     SWITCH_AMNESIA     : constant Switch_Mode := 2; 
  176.     SWITCH_BACKGROUND  : constant Switch_Mode := 3; 
  177.     SWITCH_BACKAMNESIA : constant Switch_Mode := 4; 
  178.  
  179.     SWITCH_IN  : constant Switch_Dir := 0; 
  180.     SWITCH_OUT : constant Switch_Dir := 1; 
  181.  
  182.     ---------------------------------------------------------------------------- 
  183.  
  184.     pragma Convention( C, A_Switch_Callback ); 
  185.  
  186.     pragma Import( C, Enable_Triple_Buffer, "enable_triple_buffer" ); 
  187.     pragma Import( C, Get_Color_Depth, "get_color_depth" ); 
  188.     pragma Import( C, Get_Display_Switch_Mode, "get_display_switch_mode" ); 
  189.     pragma Import( C, Get_Gfx_Mode, "get_gfx_mode" ); 
  190.     pragma Import( C, Get_Gfx_Mode_List, "get_gfx_mode_list" ); 
  191.     pragma Import( C, Get_Refresh_Rate, "get_refresh_rate" ); 
  192.     pragma Import( C, Gfx_Capabilities, "get_gfx_capabilities" ); 
  193.     pragma Import( C, Poll_Scroll, "poll_scroll" ); 
  194.     pragma Import( C, Remove_Display_Switch_Callback, "remove_display_switch_callback" ); 
  195.     pragma Import( C, Request_Refresh_Rate, "request_refresh_rate" ); 
  196.     pragma Import( C, Request_Scroll, "request_scroll" ); 
  197.     pragma Import( C, Request_Video_Bitmap, "request_video_bitmap" ); 
  198.     pragma Import( C, Scroll_Screen, "scroll_screen" ); 
  199.     pragma Import( C, Set_Color_Depth, "set_color_depth" ); 
  200.     pragma Import( C, Set_Display_Switch_Callback, "set_display_switch_callback" ); 
  201.     pragma Import( C, Set_Display_Switch_Mode, "set_display_switch_mode" ); 
  202.     pragma Import( C, Set_Gfx_Mode, "set_gfx_mode" ); 
  203.     pragma Import( C, Show_Video_Bitmap, "show_video_bitmap" ); 
  204.     pragma Import( C, Vsync, "vsync" ); 
  205.  
  206. end Allegro.Graphics;