General reorganization.

Added "static" where it makes sense. Changed variable and function names to avoid duplicates between GB and GBA. Changed include order. Changed the location of some functions to avoid some global variables and arrays. Minor fixes.