fix sort code, fix palette, pass base to ZA