'===============================================================
' A F l i b 2   W e l c o m e   P r o g r a m
'===============================================================
'This program in AFlib2 presents to you some of the absolutely
'amazing powers that this library in FreeBASIC can harness!!!
'
'Enjoy!!!  ^_-=b !
'
'
'                                        - Adigun Azikiwe Polack
'                               One of the Founders of Aura Flow
'                    Developer of "AFlib2 - Aura Flow Library 2"


Option Explicit


' First, we rev up AFlib2!!!
'---------------------------------------------------------------
'$include: 'AFlib2.bi'


' Next, we set up our arrays!
'---------------------------------------------------------------
Dim as Integer GFX.Width, GFX.Height, Lightctrl, In_and_out
Dim as ImageType AFlib2pic


' Now, setting up the graphics mode to a 320x200 resolution,
' 256 colors (8-bit), fullscreen, with 2 pages!!
'---------------------------------------------------------------
ScreenRes 320, 200, 8, 2, 1


' Let's extract the exact size of the screen resolution (using
' ScreenInfo), and get rid of that mouse pointer too!  ^-^
'---------------------------------------------------------------
ScreenInfo GFX.Width, GFX.Height
SetMouse , , 0


' Setting the work page to Page 1, with the display page set to
' Page 0 (which is gonna be the screen we can see out of!  ).
'---------------------------------------------------------------
ScreenSet 1, 0


' Initializing and loading up our BMP file here, with the
' *exact* size coordinates of the picture within this file
' indeed!
'---------------------------------------------------------------
AF2.InitSpr_BMP AFlib2pic, 160, 92, "AFlib2_mini.bmp"


' Setting up our starfield, in just ONE line!!  ^_-
'---------------------------------------------------------------
AF2.StarInit 300


Lightctrl = 0
In_and_out = 0


' Now, we display/move our starfield and show our .BMP image
' flawlessly, with custom fading of the picture itself upon
' startup and exit.  It is all done in a Do-Loop pattern here.
' You can exit this test with the "ESC" key.
' ^^
'---------------------------------------------------------------
Do

  ' Since all the blitting is being drawn on Page 1 (our work
  ' page), we first clear the screen to the color 0 with the
  ' "AF2.ClearScreen" command here before doing anything else in
  ' the loop.  Like drawing in animation frames here, you know?
  '---------------------------------------------------------------
  AF2.ClearScreen 0


  ' Let's get the starfield into display and moving to the left
  ' now!
  '---------------------------------------------------------------
  AF2.StarMotion 300, 1, 0
  AF2.StarMove 300, AF2.Left, 5


  ' Blitting our pic, with custom fades built in!! 
  '---------------------------------------------------------------
  AF2.SprBlit_brightness 0, 40, Lightctrl, @AFlib2pic.p_data[AFlib2pic.p_dataindex[1]], GFX.Width, GFX.Height


  Locate 1, 1: ? "Welcome to AFlib2!!!"


  ' Now comes the REAL magic here: we turn an ordinary 320x200
  ' graphics mode into a 160x200 MODE IN 256 COLORS, using the
  ' command "AF2.LowRes_horiz"!!!  (^-^)//
  '---------------------------------------------------------------
  AF2.LowRes_horiz


  ' Setting our custom sync to the potential of 60fps average with
  ' "AF2.CustomSync 3"!
  '---------------------------------------------------------------
  AF2.CustomSync 3


  ' We zap the contents of what we drawn into our display page
  ' (Page 0), using "ScreenCopy"!! 
  '---------------------------------------------------------------
  ScreenCopy


  ' Waiting for the user to press the "ESC" key....
  '---------------------------------------------------------------
  If inkey$ = Chr$(27) then In_and_out = 1


  ' This is our If-Then loop, where it is in position for our main
  ' Do-Loop pattern to be exited upon the user pressing the "ESC"
  ' key and our main pic fading out after that!
  '---------------------------------------------------------------
  If In_and_out = 0 then
    Lightctrl += 1: If Lightctrl > 31 then Lightctrl = 31
  End if
  If In_and_out = 1 then
    Lightctrl -= 1: If Lightctrl < 0 then Exit do
  End if

Loop


' Removing our .BMP picture array safely so that we do not
' suffer any memory leaks upon exit! 
'---------------------------------------------------------------
AF2.RemoveSpr AFlib2pic


' And that is that!!!  (^-^)v !
'----------------------------------------------------------
