Volume FKEY
Volume Number: 6
Issue Number: 5
Column Tag: Assembly Lab
Volume FKEY--Dialog Lists in Memory 
By John Holder, Eureka, CA
What’s the deal here anyway?
My first article for MacTutor™ showed you how to create an Fkey that used its
own menus and acted just like an application (refer to MacTutor™ Vol.4 No.6). This
article will show you how to create a very simple FKEY using a dialog to allow you to
change the volume level of the Macintosh speaker. It also shows how to create a Dialog
ITem List (the data normally stored in a DITL resource) in memory so your FKEY
doesn’t need any other resources.
How do I use this thing?
This Fkey was created with the Macintosh 68000 Development System. All
applications are on a disk titled ‘MDS1’ and all .D files are on a disk titled ‘MDS2’.
First assemble the file ‘Volume-Fkey.Asm’, then run the linker on the file ‘
Volume-Fkey.Link’, and finally run RMaker on the file ‘ Volume-Fkey.R’. You will
now have an FKEY ready to put into your System file!
Volume-Fkey, How it Works
When the Fkey starts, there is a short jump over its header, then the
applications current port and all registers are saved, next it brings up the standard
arrow cursor with _InitCursor. When we’ve successfully allocated storage for the
FKEYs globals and room for the dialog item list handle, we get the current value of the
speakers volume by getting the low 3 bits of the global variable ‘sdVolume’ (a byte)
and putting the value in our own global CurrentVol(A4).
Now we jump to a routine that puts the data (defined as contants at the end of the
code) into our item list handle. Now the dialog is created and the handle to our item list
is passed to the _NewDialog routine which draws the dialog and all of the items in the
list. Then we want to set the appropriate radio button depending on the current volume
level. We do this by adding 3 (the item number of the first radio button) to the
current volume level to determine which radio button to hilight and call _SetCtlValue
to set it. Now, it’s onward to the main loop!
The Main Loop
Since we’re using a dialog we can let _ModalDialog handle all the events for us.
All we have to do is wait for _ModalDialog to return an item number and jump to an
appropriate routine to handle it. If the Enter or Return key is pushed _ModalDialog
returns item number 1, which is the default button in a dialog and in this case is the
Quit button.
A click in a radio button
We’ve spotted a click on one of the radio buttons! So we put the item hit in