Everything is based on previous year's salary. The "max" is a percentage that the salary can increase year over year. The current team has an advantage in being able to offer an extra year and slightly more money.
You can go over the salary cap resigning your own players, but you can't to bring in a Free Agent.
There are some mid-level and trade salary exceptions, but I think the NBA salary cap is the best in professional sports.