implement tb77i_flags, improve direct mode, use typedef structs everywhere