#include "AFlib3_ASCii.bi"
#include "AFlib3_Miscellaneous.bi"
#include "AFlib3_Constants.bi"



Dim as Integer MDC_marker_left, MDC_marker_middle, MDC_marker_right, MDC_marker_sideleft, MDC_marker_sideright
Dim as Integer GFX_h, GFX_v


GFX_h = (640 / 8)
GFX_v = (480 / 8)
AFlibIII_SetTextGFX GFX_h, GFX_v, , 2, 0

ScreenSet 1, 0
AFlibIII_ASCii_ClearDisplay RGB(255, 0, 255)
Randomize Timer

AFlibIII_Initialize_ASCii

AFlibIII_ASCii_CaptureSprite_BMP "AF3_logo80x60.bmp", 1

AFlibIII_ASCii_Mouse_ClickSetup
AFlibIII_ASCii_ApplyMouseCursor 

Do
  AFlibIII_ASCii_GrabMouse 
  AFlibIII_ASCii_ClearDisplay RGB(0, 0, 32)

  AFlibIII_ASCii_SprBlit_alpha 0, 12, 48, 1
  
  AFlibIII_ASCii_FilledBox chr(32), 0, 0, GFX_h, 0, RGB(0, 0, 0), RGB(0, 0, 255), 17
  AFlibIII_ASCii_Print "ASCii-based MOUSE-POINTER TEST on AFlib III!!!", 5, 0, RGB(255, 255, 0), RGB(255, 0, 255), 4
  AFlibIII_ASCii_FilledBox_alpha chr(32), 0, 1, GFX_h, 5, RGB(0, 0, 0), RGB(0, 0, 0), 168, 17

  AFlibIII_ASCii_Print "X = " + str$(AFlibIII_ASCii_CheckMouse_X), 17, 1, RGB(255, 255, 255), RGB(255, 0, 255), 17
  AFlibIII_ASCii_Print "Y = " + str$(AFlibIII_ASCii_CheckMouse_Y), 17, 2, RGB(255, 255, 255), RGB(255, 0, 255), 17
  AFlibIII_ASCii_Print "Mouse Wheel = " + str$(AFlibIII_ASCii_CheckMouse_Wheel), 7, 3, RGB(255, 255, 255), RGB(255, 0, 255), 17

  AFlibIII_ASCii_Print "Mouse Buttons " + chr(205, 205, 205, 16), 26, 1, RGB(255, 0, 0), RGB(255, 0, 255), 17

  If AFlibIII_ASCii_CheckMouse_LeftClick = Active then
    If MDC_marker_left = 0 then AFlibIII_ASCii_Print "Left-Clicked!", 45, 1, RGB(255, 255, 255), RGB(255, 0, 255), 17
  Else
    If MDC_marker_left = 0 then AFlibIII_ASCii_Print_alpha "No Left-Click.", 45, 1, RGB(255, 255, 255), RGB(255, 0, 255), 31, 17
  End If

  If AFlibIII_ASCii_CheckMouse_MiddleClick = Active then
    If MDC_marker_middle = 0 then AFlibIII_ASCii_Print "Middle-Clicked!", 45, 2, RGB(255, 255, 255), RGB(255, 0, 255), 17
  Else
    If MDC_marker_middle = 0 then AFlibIII_ASCii_Print_alpha "No Middle-Click.", 45, 2, RGB(255, 255, 255), RGB(255, 0, 255), 31, 17
  End If

  If AFlibIII_ASCii_CheckMouse_RightClick = Active then
    If MDC_marker_right = 0 then AFlibIII_ASCii_Print "Right-Clicked!", 45, 3, RGB(255, 255, 255), RGB(255, 0, 255), 17
  Else
    If MDC_marker_right = 0 then AFlibIII_ASCii_Print_alpha "No Right-Click.", 45, 3, RGB(255, 255, 255), RGB(255, 0, 255), 31, 17
  End If

  If AFlibIII_ASCii_CheckMouse_LSide_Click = Active then
    If MDC_marker_sideleft = 0 then AFlibIII_ASCii_Print "Left Side Button-Clicked!", 45, 4, RGB(255, 255, 255), RGB(255, 0, 255), 17
  Else
    If MDC_marker_sideleft = 0 then AFlibIII_ASCii_Print_alpha "No Left Side Button-Click.", 45, 4, RGB(255, 255, 255), RGB(255, 0, 255), 31, 17
  End If

  If AFlibIII_ASCii_CheckMouse_RSide_Click = Active then
    If MDC_marker_sideright = 0 then AFlibIII_ASCii_Print "Right Side Button-Clicked!", 45, 5, RGB(255, 255, 255), RGB(255, 0, 255), 17
  Else
    If MDC_marker_sideright = 0 then AFlibIII_ASCii_Print_alpha "No Right Side Button-Click.", 45, 5, RGB(255, 255, 255), RGB(255, 0, 255), 31, 17
  End If
  
  If AFlibIII_ASCii_CheckMouse_LeftDoubleClick = Active then MDC_marker_left = 30
  If AFlibIII_ASCii_CheckMouse_MiddleDoubleClick = Active then MDC_marker_middle = 30
  If AFlibIII_ASCii_CheckMouse_RightDoubleClick = Active then MDC_marker_right = 30
  If AFlibIII_ASCii_CheckMouse_LSide_DoubleClick = Active then MDC_marker_sideleft = 30
  If AFlibIII_ASCii_CheckMouse_RSide_DoubleClick = Active then MDC_marker_sideright = 30
  
  MDC_marker_left -= 1
  MDC_marker_middle -= 1
  MDC_marker_right -= 1
  MDC_marker_sideleft -= 1
  MDC_marker_sideright -= 1
            
  If MDC_marker_left <= 0 then
    MDC_marker_left = 0
  else
    If (MDC_marker_left mod 6) >= 2 then AFlibIII_ASCii_Line_alpha chr(219), 45, 1, GFX_h, 1, RGB(255, 95, 0), RGB(255, 0, 255), 127, 17
    AFlibIII_ASCii_Print "Double Left-Clicked!!", 45, 1, RGB(255, 255, 255), RGB(255, 0, 255), 17
  End if

  If MDC_marker_middle <= 0 then
    MDC_marker_middle = 0
  else
    If (MDC_marker_middle mod 6) >= 2 then AFlibIII_ASCii_Line_alpha chr(219), 45, 2, GFX_h, 2, RGB(255, 95, 0), RGB(255, 0, 255), 127, 17
    AFlibIII_ASCii_Print "Double Middle-Clicked!!", 45, 2, RGB(255, 255, 255), RGB(255, 0, 255), 17
  End if

  If MDC_marker_right <= 0 then
    MDC_marker_right = 0
  else
    If (MDC_marker_right mod 6) >= 2 then AFlibIII_ASCii_Line_alpha chr(219), 45, 3, GFX_h, 3, RGB(255, 95, 0), RGB(255, 0, 255), 127, 17
    AFlibIII_ASCii_Print "Double Right-Clicked!!", 45, 3, RGB(255, 255, 255), RGB(255, 0, 255), 17
  End if

  If MDC_marker_sideleft <= 0 then
    MDC_marker_sideleft = 0
  else
    If (MDC_marker_sideleft mod 6) >= 2 then AFlibIII_ASCii_Line_alpha chr(219), 45, 1, GFX_h, 4, RGB(255, 95, 0), RGB(255, 0, 255), 127, 17
    AFlibIII_ASCii_Print "Double Left Side Button-Clicked!!", 45, 4, RGB(255, 255, 255), RGB(255, 0, 255), 17
  End if
  
  If MDC_marker_sideright <= 0 then
    MDC_marker_sideright = 0
  else
    If (MDC_marker_sideright mod 6) >= 2 then AFlibIII_ASCii_Line_alpha chr(219), 45, 3, GFX_h, 5, RGB(255, 95, 0), RGB(255, 0, 255), 127, 17
    AFlibIII_ASCii_Print "Double Right Side Button-Clicked!!", 45, 5, RGB(255, 255, 255), RGB(255, 0, 255), 17
  End if
  
  AFlibIII_ASCii_Line_alpha chr(32), 0, GFX_v - 1, GFX_h, GFX_v - 1, RGB(0, 0, 0), RGB(0, 0, 0), 168, 17
  AFlibIII_ASCii_Print "When you are done, please press [ESC] to exit.", 7, GFX_v - 1, RGB(255, 255, 255), RGB(255, 0, 255), 17
  AFlibIII_ASCii_DisplayMouseCursor
  ScreenCopy
  AFlibIII_CustomSync 64
Loop until MultiKey(&h01) or AFlibIII_Detect_CloseWindow



AFlibIII_ASCii_RemoveSprite_CleanSweep
AFlibIII_DeInit_ASCii

AFlibIII_EndProgram

