INCLUDEPATH "$\inc\"
  '$FILENAME  "O2Squash.exe"
  'INCLUDE    "Rtl32.inc"
  INCLUDE "Console.inc"
  
  ! FUNCTION GetTickCount     LIB "KERNEL32.DLL" () AS DWORD
  ! SUB Sleep                 LIB "KERNEL32.DLL" (DWORD mSecs)
  ! SUB GetConsoleCursorInfo  LIB "KERNEL32.DLL" (DWORD hConsoleOutput, DWORD lpConsoleCursorInfo)
  ! SUB SetConsoleCursorInfo  LIB "KERNEL32.DLL" (DWORD hConsoleOutput, DWORD lpConsoleCursorInfo)
  ! SUB SetConsoleWindowInfo  LIB "KERNEL32.DLL" (DWORD hConsoleOutput, DWORD bAdsolute, DWORD lpConsoleWindow)
  ! FUNCTION GetConsoleWindow LIB "KERNEL32.DLL" () AS DWORD
  ! FUNCTION GetSystemMenu    LIB "USER32.DLL"   (DWORD hWnd, DWORD bRevert) AS DWORD
  ! FUNCTION GetAsyncKeyState LIB "USER32.DLL"   (DWORD dwKeyKode) AS DWORD
  ! SUB DeleteMenu            LIB "USER32.DLL"   (DWORD hMenu, DWORD uPosition, DWORD uFlags)
  
  TYPE CONSOLE_CURSOR_INFO
    DWORD dwSize
    DWORD bVisible
  END TYPE
  
  DIM ConsoleCursorInfo AS CONSOLE_CURSOR_INFO
  DIM ConsoleWindow AS SMALL_RECT
  DIM hMenu AS DWORD
  
  #DEFINE VK_ESCAPE           27
  #DEFINE VK_LEFT             37
  #DEFINE VK_RIGHT            39
  #DEFINE TICKS()             GetTickCount()
  #DEFINE CLOCK()             ROUND(TICKS() / 1000)
  #DEFINE DROWSE()            Sleep(10)
  #DEFINE DISPLAY(A, B, C)    SetPos(B - 1, A): PRINT C
  #DEFINE GETKEYB(A)          GetAsyncKeyState(A)
  #DEFINE CURSOFF()           GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), @ConsoleCursorInfo): ConsoleCursorInfo.bVisible = 0: SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), @ConsoleCursorInfo)
  #DEFINE SETCONS()           ConsoleWindow.Right = 18: ConsoleWindow.Bottom = 18: SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), 1, @ConsoleWindow): SetConsoleTitle("DO IT!")
  #DEFINE FIXCONS()           hMenu = GetSystemMenu(GetConsoleWindow(), 0): DeleteMenu(hMenu, &HF000, 0): DeleteMenu(hMenu, &HF020, 0): DeleteMenu(hMenu, &HF030, 0)
  
  ' ========= HERE WE GO! =========
  DIM AS SYS X, H
  DIM AS SYS Y, V
  DIM AS SYS O, P
  DIM AS SYS R, S
  DIM AS SYS T1 = TICKS(), T2, T3
  DIM AS STRING T4

  CURSOFF()
  SETCONS()
  FIXCONS()
  
  CLS
  DISPLAY(1, 1, "===================")
  DISPLAY(3, 4, "OXYGEN SQUASH")
  DISPLAY(5, 1, "===================")
  DISPLAY(8, 2, "BROUGHT TO YOU BY")
  DISPLAY(10, 5, "THE WATCHER")
  DISPLAY(18, 2, "ENTER TO START...")
  WAITKEY()

  START:
  CLS
  X = 10: IF (TICKS() AND 9) > 4 THEN H = 1 ELSE H = -1
  Y = 15: V = -1
  R = 10: S = 0
  T3 = CLOCK()
  
  DISPLAY(16, R, "==")
  WHILE Y <= 16
        T4 = "TIME: " & clock() - T3
  	O = X: P = Y
  	X = X + H: Y = Y + V
  	DISPLAY(18, 1, "SCORE: " & S)
  	DISPLAY(18, 19 - LEN(T4), T4)
  	DISPLAY(Y, X, "o")
  	DISPLAY(P, O, " ")
  
  	IF GETKEYB(VK_ESCAPE) THEN GOTO FINISH
  	IF GETKEYB(VK_LEFT) <> 0 AND R >= 1 THEN
  		P = R
  		R = R - 2
  		IF R < 1 THEN R = 1
  		DISPLAY(16, P, "  ")
  		DISPLAY(16, R, "==")
  	ELSE IF GETKEYB(VK_RIGHT) <> 0 AND R <= 17 THEN
  		P = R
  		R = R + 2
  		IF R > 19 THEN R = 19
  		DISPLAY(16, P, "  ")
  		DISPLAY(16, R, "==")
  	END IF
  
  	IF X + H < 1 OR X + H > 19 THEN H = -H
  	IF Y + V < 1 THEN V = -V
  	IF Y + V > 15 AND X + H >= R AND X + H <= R + 1 THEN
  		V = -V
  		S = S + 1
  		IF (X + H = R AND H > 0) OR (X + H = R + 1 AND H < 0) THEN H = -H
  	END IF
  	WHILE T2 - T1 < 50
  		T2 = TICKS()
  		DROWSE()
  	WEND
  	T1 = TICKS()
  WEND
  GOTO START
  
  FINISH:
  END
  ' ========= THAT'S IT! ==========



