Classic Computer Magazine Archive START VOL. 1 NO. 2 / FALL 1986



by Dan Moore and David Small

"Macintize" your drop-down menus and prevent cursor clutter. The Amazing MouseTrap will lock out the menu bar until you really need it. No more accidental drop downs. Program and listing are in the MOUSTRAR.STQ folder on your START disk.

There you are, working on your program. The mouse is near the top of the page. With the delicacy of a microsurgeon, you avoid that overzealous menu bar as you move items around onscreen.

But, oh no! You breathed on the mouse! It jogs up a millimeter and a drop-down menu hops right on top of your file icon - for the fiftieth time this hour! Aiigh!

Tired of this scenario? Frustrated by interfering drop-down menus? Weary of nagging obstacles?

Then what you need is the Dandy Dan Moore MouseTrap!

With this amazing program, you have not one, but two programs in one! The first routine, The Berlin Wall, prevents you from ever hitting the menu bar accidentally; it erects a wall between the main screen and the menu bar. Try as you will, you cannot cross up into that menu bar The second routine, The Amazing Clicker, makes the right mouse button pop you up to the menu bar, no matter where you are. You can be at the bottom of the screen, the top, or (God forbid!) visiting IBM headquarters in Boca Raton, and if you press the right button, boom! You're in the menu bar, and (gasp!) the menus pull down.

I know, you're stunned. But try to be calm. It is all in one program, MOUSTRAP.PRG. Slip it inside a sleeping AUTO folder on your boot disk, and you're set.

Just how did I accomplish this miracle? It all started one dark and stormy night. I accidentally pulled down a menu bar, and decided there had to be a better way. Somewhere, a dog was barking. So, I went hunting for the low memory variables that control the mouse. Since they aren't documented in the Atari papers, I had to look for them

The search method was rather novel. First, using an XBIOS command, I instructed the video chip to begin displaying memory at location 0. This gave me a bit-map view of the first 32K of the hard way memory. While moving the mouse around, I looked for blinking pixels which seemed to represent the mouse X and Y registers. Upon finding them, I measured with a ruler from the top of the screen, divided against a 32K screen size, and got an approximate memory location of the blinking pixels. I then used SID, the Developer's Kit debugger, to determine the exact location. No kidding, that's how I did it.

My stunningly commented listing illustrates the action of the program. (See MOUSTRAPS in the MOUSTRAP.STQ folder on your START disk.) Each mouse exception, I intercept a three-byte, relative mouse packet (button, X delta, Y delta), then calculate where the mouse will end up after the current movement is complete. If the mouse will end up at the top of the screen, I cruelly prevent it by zeroing the Y component of the mouse movement. Then, there's a right button check. If the right button is depressed, I tell it to move up 128 pixels four times. This ensures that no matter where it is on the screen, it ends up at the top in one magic jump.

You will note that I wedge this routine in the mouse-packet exception vector" whose address can be determined with the keyboard-vector XBIOS call.

So much for the heart of the program. How do I make it stay resident in memory? I first tried MOUSTRAP as a desk accessory, but room for those is precious and limited, so instead I went for a terminate-and-stay-resident program designed for an AUTO folder There is a catch here, alas. After AUTO folder programs are run, GEM reinitializes the mouse vectors through Initmouse(), effectively demolishing my own custom vectors. To solve this, I stole the Trap 14 jump vector, and prevented GEM from clobbering my jump table.

Bells and whistles included making it work with the color monitors (less scan lines in the sensitive region), adding real live comments to the code, and polishing off a six-pack from the fridge to get me through.

Users of the few programs that use the right button should note that conflicts can occur with the MouseTrap. Don't load it in with DEGAS or NEOCHROME, but otherwise, you will probably be fine.

(Editor's note: The MouseTrap code can be adapted to your own nefarious schemes. One of the practical jokers at START created MOUSEGAG.PRG (also in the MOUSTRAP.STQ folder). Sneak it into a friend's AUTO folder and watch the fun.)