; This file holds all the functions If it gets too big,
; we can split it in categories

; *****************************************************************************
; * Tileset
Procedure InitGraphics()
  GFXLogo = LoadSprite(#PB_Any, "../data/gfx/logo.bmp")
  GFXTileset = LoadSprite(#PB_Any, "../data/gfx/tileset01.bmp")
EndProcedure

Procedure InitTileset()
  Tileset(0) = CopySprite(GFXTileset, #PB_Any)
  ClipSprite(Tileset(0), 0, 0, 16, 16)
  
  Tileset(1) = CopySprite(GFXTileset, #PB_Any)
  ClipSprite(Tileset(1), 16, 0, 16, 16)
  
  Tileset(2) = CopySprite(GFXTileset, #PB_Any)
  ClipSprite(Tileset(2), 32, 0, 16, 16)
EndProcedure

Procedure DrawTile(number.i, x.i, y.i)
  DisplaySprite(Tileset(number), x, y)
  
  ;Debug number.i
  ;Debug x.i
  ;Debug y.i
EndProcedure

Procedure DrawMap()
  DrawTile(0, 0, 0);
  DrawTile(0, 16, 0);
  DrawTile(0, 32, 0);
  DrawTile(0, 48, 0);
  DrawTile(0, 64, 0);
  DrawTile(0, 80, 0);
  DrawTile(0, 96, 0);
  
  DrawTile(0, 0, 16);
  DrawTile(0, 16, 16);
  DrawTile(0, 32, 16);
  DrawTile(0, 48, 16);
  DrawTile(0, 64, 16);
  DrawTile(0, 80, 16);
  DrawTile(0, 96, 16);
  
  DrawTile(1, 0, 32);
  DrawTile(1, 16, 32);
  DrawTile(1, 32, 32);
  DrawTile(0, 48, 32);
  DrawTile(1, 64, 32);
  DrawTile(1, 80, 32);
  DrawTile(1, 96, 32);
  
  DrawTile(0, 0, 48);
  DrawTile(0, 16, 48);
  DrawTile(0, 32, 48);
  DrawTile(0, 48, 48);
  DrawTile(0, 64, 48);
  DrawTile(0, 80, 48);
  DrawTile(0, 96, 48);
  
  DrawTile(2, 0, 64);
  DrawTile(2, 16, 64);
  DrawTile(2, 32, 64);
  DrawTile(2, 48, 64);
  DrawTile(2, 64, 64);
  DrawTile(2, 80, 64);
  DrawTile(2, 96, 64);
EndProcedure

Procedure DrawGui()
  Debug "This is an awesome Gui"
EndProcedure

; *****************************************************************************
; * Menu

Procedure Menu_GotoCurrent()
  If *ActiveMenu\Entries()\Selected <> #True
    FirstElement(*ActiveMenu\Entries());
    
    ForEach *ActiveMenu\Entries()
      If *ActiveMenu\Entries()\Selected = #True
        Break
      EndIf
    Next
  EndIf
EndProcedure


