How to Create ToolBoxNewOS, ToolBoxNewTool for New ROM Calls (43561)
The information in this article applies to:
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b
This article was previously published under Q43561 SUMMARY
Listed below are the steps necessary to create two new Toolbox
statements required to access the new ROM routines listed in Volumes
IV and V of "Inside Macintosh" (by Apple Computer, published by
Addison-Wesley), and revised ROM routines in Volumes I, II, and III.
This information applies to Microsoft QuickBasic versions 1.0, 1.0a,
and 1.0b for Apple Macintosh.
MORE INFORMATION
The address of certain ROM routines in "Inside Macintosh," Volumes IV
and V, and revised ROM routines listed in Volumes I, II, and III, are
not accessible through the standard Toolbox statement (which is an
MBLC routine) packaged with QuickBasic. To call these additional
routines, you need to modify Macintosh QuickBasic with the ResEdit
utility.
This situation occurs because QuickBasic uses _GetTrapAddress to
obtain the address of the "trap" specified in the ToolBox MBLC. This
procedure doesn't work correctly with the new "traps" that are listed
in "Inside Macintosh," Volumes IV and V, and for the revised ROM
routines in Volumes I, II, and III. For a detailed explanation of how
_GetTrapAddress is used, refer to Page 234 of "Inside Macintosh,"
Volume IV.
To make all ROM routines accessible to QuickBasic, two new Toolbox
library routines need to be created. The two new Toolbox routines are
used for the following:
- Old ROM routines that have not been revised
- The new Operating System routines
- The new Toolbox routines
On the second part of this document is an example showing how to use
the revised ROM routine NEWPTR. Pages 497-524 of the "Microsoft
QuickBasic for Apple Macintosh: Language Reference" manual discuss how
to call the existing Toolbox statement.
Use the following steps to create the two new Toolbox statements
ToolBoxNewOS and ToolBoxNewTool:
- Invoke ResEdit.
- Open QuickBasic (b) or (d).
- Double-click the MBLC resource in the Microsoft QuickBasic (b) or
(d) window.
- Scroll down to MBLC "Toolbox" ID = 3550.
- Click the MBLC "ToolBox" ID = 3550.
- From the Edit menu, choose Duplicate.
- Choose Duplicate from the Edit menu a second time.
- Double-click the first MBLC "ToolBox" ID = nnnn to open the window
that displays the code for that routine.
- From the File menu, choose Get Info.
- Change the "Name:" field from "ToolBox" to ToolBoxNewOS.
- Close the "Info for MBLC nnnn from QuickBasic" window.
- From the Search menu, choose Find Hex.
- Put a146 in the "Find Hex:" field.
- Put a346 in the "Change To:" field.
- Choose the Change All button.
- Choose the OK button in the Alert box.
- Close the Change Hex window.
- Close the MBLC "ToolboxNewOS" ID = nnnn window.
- Double-click the second MBLC "ToolBox" ID = nnnn to open the window
that displays the code for that routine.
- From the File menu, choose Get Info.
- Change the "Name:" field from "ToolBox" to ToolBoxNewTOOL.
- Close the "Info for MBLC nnnn from QuickBasic" window.
- From the Search menu, choose Find Hex.
- Put a146 in the "Find Hex:" field.
- Put a746 in the "Change To:" field.
- Choose the Change All button.
- Choose the OK button in the Alert box.
- Close the Change Hex window.
- Close the MBLC "ToolboxNewTOOL" ID = nnnn window.
The next step is to decide which Toolbox routine should be used. Page
13 of "Inside Macintosh," Vol. IV, states the following:
Bit 11 of the trap word determines how the remainder of the word
will be interpreted; usually it's "0" for Operating System calls
and "1" for ToolBox calls, though there can be exceptions.
As a general rule, try to use the "ToolBox" statement first. If that
fails, examine bit 11 of the trap number and use "ToolBoxNewTool" or
"ToolBoxNewOS" if it is a "0" or "1," respectively.
For example, because bit 11 of NewPtr is 0, you know that NewPtr is an
Operating System call. Listed in the back of Volumes III, IV, and V of
"Inside Macintosh" are the SYSTEM TRAPS for each routine call. The
number listed is in hexadecimal notation; therefore, the number must
be converted into binary so that bit 11 can be checked. The following
is an example showing how to allocate a block of memory using Newptr:
DIM regsarray&(5)
size& = 0
Newptr& = &HA11E
ToolboxNewOS "I"
ToolboxNewOS "R",NewPtr&,regsarray&(0),,,(size&)
PRINT HEX$(regsarray&(2)) 'print out the pointer
PRINT regsarray&(0) 'print out the error, 0 if none
Modification Type: | Major | Last Reviewed: | 10/20/2003 |
---|
Keywords: | KB43561 |
---|
|