Press 'tab' once you start MAME, and go to 'Input (General)' and then go to player 1 controls, and map all the appropriate analog controls to your trackball (paddle, trackX, trackY, dial, etc). To map, press enter and then spin the trackball either horizontally (for X) or vertically (for Y). Once you do this, it should be saved for all games in which mouse is enabled.