'=============================================================== 
' A F l i b   I I I   G F X   T w e a k   E x a m p l e   # 2
'=============================================================== 
'
'In this second graphical tweak example of this stepped-up game
'lib called AFlib III, again, prepare to experience the amazing
'graphics transformation as I show you this time how to tweak a
'normal full-screen graphics mode *horizontally*, EASY, without
'having to do all of that complex programming in order for you
'to get there!!!  And the sheer magnificence begins with only
'this one command:
'
'                ---- AFlibIII_LowRes_horiz ----
'
'.....because this is where it gets good!!!  ;) !  For example,
'take a 640x480 full-screen graphics mode.  Then, if you use
'this command, it will tweak the mode into an all-new 320x480
'graphics mode plain and simple!!!  ^-^=b !
'
'Remember that this command indeed are FULLY supported in all
'15-, 16-, 24-, and 32-bit modes only, so do not miss this
'opportunity in your FreeBASIC programs!!!
' 
'In the meantime, do enjoy this wonderful example, and God truly
'bless all of you!!!  :D
' 
' 
'                                        - Adigun Azikiwe Polack 
'                               One of the Founders of Aura Flow 
'                                       Developer of "AFlib III" 
'---------------------------------------------------------------


#include "AFlib3_Sprite.bi"
#include "AFlib3_Font.bi"
#include "AFlib3_Screen.bi"
#include "AFlib3_Miscellaneous.bi"

Dim Full_or_Windowed as integer = 0 '<----- Pass '0' for Windowed Mode; or
                                    '            '1' for Fullscreen Mode.



Declare Sub ShadowPrint ( Byref text as String, _ 
                          Byval x as Integer, Byval y as Integer, _ 
                          Byval col as Integer, Byval sh_x as Integer, _ 
                          Byval sh_y as Integer, Byval sh_col as Integer, _ 
                          Byval chara_id as Integer ) 


'========================================================================== 
'/////// S T A R T   O F   M A I N   P O R T I O N 
'========================================================================== 

Dim BitDepth as Integer

ScreenRes 424, 96 , , 0
Windowtitle "AFlib III -- GFX Tweak #2"
Color 15, 1: ? "          Please select your color depth!!!          "
Locate 4: Color 15, 0
Locate , 17: Color 10: ? "[1] ";: Color 14: ? "- 15-bit color": ?
Locate , 17: Color 10: ? "[2] ";: Color 14: ? "- 16-bit color": ?
Locate , 17: Color 10: ? "[3] ";: Color 14: ? "- 24-bit color": ?
Locate , 17: Color 10: ? "[4] ";: Color 14: ? "- 32-bit color"

Do
  Select case Inkey$
    Case "1": BitDepth = 15: Exit Do
    Case "2": BitDepth = 16: Exit Do
    Case "3": BitDepth = 24: Exit Do
    Case "4": BitDepth = 32: Exit Do
  End Select
Loop
Cls

ScreenRes 424, 280, , , 0
Color 15, 1: ? "         Please select your graphics mode!!!         "
Locate 4: Color 15, 0
Locate , 27: Color 10: ? "[1] ";: Color 14: ? "- 320x200"
Locate , 27: ?
Locate , 27: Color 10: ? "[2] ";: Color 14: ? "- 320x240"
Locate , 27: ?
Locate , 27: Color 10: ? "[3] ";: Color 14: ? "- 400x300"
Locate , 27: ?
Locate , 27: Color 10: ? "[4] ";: Color 14: ? "- 512x384"
Locate , 27: ?
Locate , 27: Color 10: ? "[5] ";: Color 14: ? "- 640x400"
Locate , 27: ?
Locate , 27: Color 10: ? "[6] ";: Color 14: ? "- 640x480"
Locate , 27: ?
Locate , 27: Color 10: ? "[7] ";: Color 14: ? "- 720x480"
Locate , 27: ?
Locate , 27: Color 10: ? "[8] ";: Color 14: ? "- 720x576"
Locate , 27: ?
Locate , 27: Color 10: ? "[9] ";: Color 14: ? "- 800x600"
Locate , 27: ?
Locate , 27: Color 10: ? "[0] ";: Color 14: ? "- 1024x768"
Locate , 27: ?
Locate , 27: Color 10: ? "[A] ";: Color 14: ? "- 1152x864"
Locate , 27: ?
Locate , 27: Color 10: ? "[B] ";: Color 14: ? "- 1280x720"
Locate , 27: ?
Locate , 27: Color 10: ? "[C] ";: Color 14: ? "- 1280x1024"
Locate , 27: ?
Locate , 27: Color 10: ? "[D] ";: Color 14: ? "- 1600x1200"
Locate , 27: ?
Locate , 27: Color 10: ? "[E] ";: Color 14: ? "- 1920x1080"
Locate 6, 5: Color 15: ? BitDepth; "-bit color"
Locate 7, 10: Color 15: ? "is selected!"

Do
  Select case Inkey$
    Case "1": ScreenRes 320, 200, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "2": ScreenRes 320, 240, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "3": ScreenRes 400, 300, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "4": ScreenRes 512, 384, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "5": ScreenRes 640, 400, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "6": ScreenRes 640, 480, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "7": ScreenRes 720, 480, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "8": ScreenRes 720, 576, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "9": ScreenRes 800, 600, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "0": ScreenRes 1024, 768, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "A", "a": ScreenRes 1152, 864, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "B", "b": ScreenRes 1280, 720, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "C", "c": ScreenRes 1280, 1024, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "D", "d": ScreenRes 1600, 1200, BitDepth, 2, Full_or_Windowed: Exit Do
    Case "E", "e": ScreenRes 1920, 1080, BitDepth, 2, Full_or_Windowed: Exit Do
  End Select
Loop
SetMouse , , 0

Dim as Integer Screen_h, Screen_v
SetMouse , , 0

Windowtitle "AFlib III -- GFX Tweak #2"
SetMouse , , 0

'---------------------------------------------------- 
ScreenSet 1, 0 
AFlibIII_PrepareCharTrans 0, 0
AFlibIII_DisplayAllChars 0, 0, 0, &hffffff, 0, 28
AFlibIII_OptimizeFontSet 0, 0, 1
ScreenSet 0, 0 
'----------------------------------------------------

Randomize Timer

Dim as integer e, Scr_horiz, Scr_vert
ScreenInfo Scr_horiz, Scr_vert 

AFlibIII_ClearDisplay 0: Color rgb(255,255,255), 0

? "Take a normal "; Str$(Scr_horiz); "x"; Str$(Scr_vert); " graphics mode"
? "in GFXlib2 for FreeBASIC, add the new"
? "AFlib III with higher than 8bpp,"
? "and such *amazing* things can happen,"
? "like this!!"
AFlibIII_Delay 750

AFlibIII_ClearDisplay 0

Scr_horiz /= 2

For e = 0 TO 450
  Line (int(rnd(1)*Scr_horiz)+1, int(rnd(1)*Scr_vert)+1)-(int(rnd(1)*Scr_horiz)+1, int(rnd(1)*Scr_vert)+1), rgb(int(rnd(1)*80) + 1, int(rnd(1)*80) + 1, int(rnd(1)*80) + 1)
next

View (0, 0)-(Scr_horiz / 2, Scr_vert / 2)

For e = 0 TO 450
  Line (int(rnd(1)*Scr_horiz)+1, int(rnd(1)*Scr_vert)+1)-(int(rnd(1)*Scr_horiz)+1, int(rnd(1)*Scr_vert)+1), int(rnd(1)*&hffffff) + 1, bf
next

AFlibIII_Delay 300

View (0, 0)-(Scr_horiz * 2, Scr_vert * 2)

ScreenLock

ShadowPrint Str$(Scr_horiz) + "x" + Str$(Scr_vert) + "x" + Str$(BitDepth) + "bpp", 0, 0, rgb(255,255,255), 1, 1, rgb(0,0,0), 1
ShadowPrint "Pseudo Graphics", 24, 8, rgb(255,255,255), 1, 1, rgb(0,0,0), 1
ShadowPrint "Resolution!!!", 24, 16, rgb(255,255,255), 1, 1, rgb(0,0,0), 1
ShadowPrint "Exclusively in", 0, 40, rgb(32,255,32), 1, 1, rgb(0,32,0), 1

If Scr_horiz > 256 then
  ShadowPrint "AFlib III for FreeBASIC!!!", 24, 48, rgb(32,255,32), 1, 1, rgb(0,32,0), 1
else
  ShadowPrint "AFlib III", 24, 48, rgb(32,255,32), 1, 1, rgb(0,32,0), 1
  ShadowPrint "for FreeBASIC!!!", 24, 56, rgb(32,255,32), 1, 1, rgb(0,32,0), 1
End if

If Scr_horiz >= 200 then
  ShadowPrint "Custom mode by", 0, Scr_vert - 48, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "Adigun Azikiwe Polack.", 0, Scr_vert - 40, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
else
  ShadowPrint "Custom mode by", 0, Scr_vert - 56, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "Adigun Azikiwe", 0, Scr_vert - 48, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "Polack.", 104, Scr_vert - 40, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
End if

If Scr_horiz >= 240 then
  ShadowPrint "(c)2005-2016", 0, Scr_vert - 24, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "Adigun Azikiwe Polack/Aura Flow.", 0, Scr_vert - 16, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "All Rights Reserved.", 0, Scr_vert - 8, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
else
  ShadowPrint "(c)2005-2016", 0, Scr_vert - 24, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "AAP/Aura Flow.", 0, Scr_vert - 16, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
  ShadowPrint "All Rights Reserved.", 0, Scr_vert - 8, rgb(128,128,128), 1, 1, rgb(25,25,25), 1
End if

AFlibIII_LowRes_horiz  '<---- Let's unlock the magic now!!!  ^-^ !

ScreenUnlock

AFlibIII_RemoveFontSet 1

AFlibIII_ClearKeyBuffer
Sleep

AFlibIII_EndProgram

'========================================================================== 
'/////// E N D   O F   M A I N   P O R T I O N 
'========================================================================== 




'__________________________________________________________________________ 
Sub ShadowPrint ( Byref text as String, _ 
                  Byval x as Integer, Byval y as Integer, _ 
                  Byval col as Integer, Byval sh_x as Integer, _ 
                  Byval sh_y as Integer, Byval sh_col as Integer, _ 
                  Byval chara_id as Integer ) 

AFlibIII_OptimizedPrint_color text, x + sh_x, y + sh_y, chara_id, 0, sh_col
AFlibIII_OptimizedPrint_color text, x, y, chara_id, 0, col

End Sub