Why does the screen rotate?

Has anyone else had this problem? Today I tried MAME 32K.64 and got it to start up okay. But a few minutes into any given game, the screen starts flipping out and I’m getting a notice telling me that the program had to close. Weird thing is, the screen is either upside down or rotated 90 degrees to the right. Anyone know why this is?