package.path=package.path..";C:\\Users\\micro\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\rift\\?.lua"	-- jtruk
package.path=package.path..";C:\\Users\\Ronan\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\rift\\?.lua"	-- Mantratronic
package.path=package.path..";C:\\Users\\matt\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\rift\\?.lua"	-- jynx

local R={}
require("./sys/sys")(R)
require("./ui/gui")(R)

local GUI=nil

function BOOT()
    trace("boot")
    GUI=R.Gui:new()
    GUI:setEventCb(function(m,hits)
        print(string.format("BTN %s%s%s",
            m.lb and "L" or "-",
            m.mb and "M" or "-",
            m.rb and "R" or "-"),
            0,10,2
        )

        print(string.format("BTNP %s%s%s",
            m.lbp and "L" or "-",
            m.mbp and "M" or "-",
            m.rbp and "R" or "-"),
            0,20,2
        )

        for i=1,#hits do
            local h=hits[i]
            print(string.format("%s: %d,%d", h.id, h.x, h.y),0,20+10*i,2)
        end
    end)

    local b=R.Button:new('btn-high',50,65,80,20)
    GUI:addButton(b)

    local b=R.Button:new('btn-low',50,100,80,20)
    GUI:addButton(b)

    local b=R.Button:new('btn-vert',80,50,30,80)
    GUI:addButton(b)
end

TIC=R.ticWrap(function()
    cls()
    R.tryBreak()

    GUI:update()
    local hits=GUI:getHits()
    print(string.format("Hits: %d",#hits),0,0,5)

    GUI:draw()
end)

-- <PALETTE>
-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
-- </PALETTE>

