Cur_X%=(LCD_WIDTH+1)\2
Cur_Y%=(LCD_HEIGHT+1)\2
Cur_Time%=2
Cur_Time_Count%=0
Gosub Main

Procedure Main
  Cls
  Gosub Cursor_Create
  Gosub Cursor_Show(Cur_X%,Cur_Y%,0)
  Do
    Cur_Time_Count%=Timer
    While (Timer()-Cur_Time_Count%)<Cur_Time%
    
      If RR_ESC Then
        End
      Endif
    Wend
    Gosub Cursor_Move
  Loop
Return

Procedure Cursor_Move
  Local Key!,Cur_Xx%,Cur_Yy%
  
  Key!=FALSE
  Cur_Xx%=Cur_X%
  Cur_Yy%=Cur_Y%

  If RR_LEFT Then
    Dec Cur_X%
    Key!=TRUE
  Elseif RR_RIGHT Then
    Inc Cur_X%
    Key!=TRUE
  Endif
  If RR_UP Then
    Dec Cur_Y%
    Key!=TRUE
  Elseif RR_DOWN Then
    Inc Cur_Y%
    Key!=TRUE
  Endif  
  
  If Key! Then     
    If Cur_X%>LCD_WIDTH Then
      Cur_X%=LCD_WIDTH
    Else If Cur_X%<0 Then
      Clr Cur_X%
    Endif
    
    If Cur_Y%>LCD_HEIGHT Then
      Cur_Y%=LCD_HEIGHT
    Else If Cur_Y%<0 Then
      Clr Cur_Y%
    Endif

    Gosub Cursor_Show(Cur_Xx%,Cur_Yy%,1)
    Gosub Cursor_Show(Cur_X%,Cur_Y%,0)
  Endif
Return

Procedure Cursor_Show(X%,Y%,Mode%)
  Sprite Cursor_Sprite$,X%,Y%,Mode%
Return

Procedure Cursor_Create
  Local I%
  Cursor_Sprite$=Mki$(0)+Mki$(0)+Mki$(&H0010)
  Restore Cursor_Data
  For I%=1 To 16
    Read Data%
    Cursor_Sprite$=Cursor_Sprite$+Mki$(Data%)
  Next I%
Return

Cursor_Data:
Data &H8000,&HC000,&HE000,&HF000
Data &HF800,&HFC00,&HFE00,&HFF00
Data &HF800,&HD800,&H8C00,&H0C00
Data &H0600,&H0600,&H0000,&H0000