" Apple®Inside Macintosh Volume ill •• • Accounts Inside Macintosh@ Volume III .... ...... Addison-Wesley Publishing Company, Inc. Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Copyright© 1985 by Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Computer, Inc. Printed in the United States of America. ©Apple Computer, Inc., 1985 20525 Mariani A venue Cupertino, CA 95014 (408) 996-1010 Apple, the Apple logo, LaserWriter, Lisa, Macintosh, the Macintosh logo, and MacWorks are registered trademarks of Apple Computer, Inc. MacDraw, MacPaint, and MacWrite are registered trademarks of Claris Corporation. Simultaneously published in the United States and Canada. Written by Caroline Rose with Bradley Hacker, Robert Anders, Katie Withey, Mark Metzler, Steve Chernicoff, Chris Espinosa, Andy Averill, Brent Davis, and Brian Howard, assisted by Sandy Tompkins-Leffler and Louella Pizzuti. Special thanks to Cary Clark and Scott Knaster. This book was produced using the Apple Macintosh computer and the LaserWriter printer. ISBN 0-201-17733-1 KLMNOPQRST-MU-93210 11th printing, June 1990 Inside Macintosh Volume III WARRANTY INFORMATION ALL IMPLIED WARRANTIES ON THIS MANUAL, INCLUDING IMPLIED WARRANTIES OF MERCHANTAillLITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF THE ORIGINAL RETAIL PURCHASE OF THIS PRODUCT. Even though Apple has reviewed this manual, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS MANUAL IS SOLD "AS IS," AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition lo this warranty. Some stales do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. Contents 1 Preface 3 About Inside Macintosh 4 A Horse of a Different Color 5 The Structure of a Typical Chapter 5 Conventions 7 1 Finder Interface 9 About This Chapter 9 Signatures and File Types 15 2 The Macintosh Hardware 17 About This Chapter 17 Overview of the Hardware 18 The Video Interface 20 The Sound Generator 22 The sec 25 The Mouse 29 The Keyboard and Keypad 33 The Disk Interface 36 The Real-Time Clock 39 The VIA 42 System Startup 43 Summary 47 3 Summary 49 About This Chapter 50 AppleTalk Manager 65 Binary-Decimal Conversion Package 66 Control Manager 71 Desk Manager 73 Device Manager 80 Dialog Manager 85 Disk Driver 88 Disk Initialization Package 90 Event Manager, Operating System 94 Event Manager, Toolbox 98 File Manager 113 Font Manager 118 International Utilities Package Inside Macintosh 124 Memory Manager 130 Menu Manager 134 Package Manager 135 Printing Manager 141 QuickDraw 154 Resource Manager 157 Scrap Manager 159 Segment Loader 161 Serial Drivers 165 Sound Driver 172 Standard File Package 176 System Error Handler 179 TextEdit 184 Utilities, Operating System 190 Utilities, Toolbox 193 Vertical Retrace Manager 195 Window Manager 201 Assembly Language 205 Appendix A: Result Codes 211 Appendix B: Routines That May Move or Purge Memory 215 Appendix C: System Traps 227 Appendix D: Global Variables 233 Glossary 261 Index PREFACE 3 Aboutlnside Macintosh 3 The Language 4 What's in Each Volume 4 Version Numbers 4 A Horse of a Different Color 5 The Structure of a Typical Chapter 5 Conventions Contents Ill-I Inside Macintosh III-2 Preface ABOUT INSIDE MACINTOSH Inside Macintosh is a three-volume set of manuals that tells you what you need to know to write software for the Apple® Macintosh™ 128K, 512K, or XL (or a Lisa® running MacWorks™ XL). Although directed mainly toward programmers writing standard Macintosh applications, Inside Macintosh also contains the information needed to write simple utility programs, desk accessories, device drivers, or any other Macintosh software. It includes: • the user interface guidelines for applications on the Macintosh • a complete description of the routines available for your program to call (both those built into the Macintosh and others on disk), along with related concepts and background information •a description of the Macintosh 128K and 512K hardware It does not include information about: • Programming in general. • Getting started as a developer. For this, write to: Developer Relations Mail Stop 27-S Apple Computer, Inc. 20525 Mariani A venue Cupertino, CA 95014 •Any specific development system, except where indicated. You'll need to have additional documentation for the development system you're using. •The Standard Apple Numeric Environment (SANE), which your program can access to perform extended-precision floating-point arithmetic and transcendental functions. This environment is described in the Apple Numerics Manual. You should already be familiar with the basic information that's in Macintosh, the owner's guide, and have some experience using a standard Macintosh application (such as MacWrite™). The Language The routines you'll need to call are written in assembly language, but (with a few exceptions) they're also accessible from high-level languages, such as Pascal on the Lisa Workshop development system. Inside Macintosh documents the Lisa Pascal interfaces to the routi nes and the symbolic names defined for assembly-language programmers using the Lisa Workshop; if you're using a different development system, its documentation should tell you how to apply the information presented here to that system. Inside Macintosh is intended to serve the needs of both high-level language and assembly- language programmers. Every routine is shown in its Pascal form (if it has one), but assembly- language programmers are told how they can access the routines. Information of interest only to assembly-language programmers is isolated and labeled so that other programmers can conveniently skip it. About Inside Macintosh III-3 Inside Macintosh Familiarity with Lisa Pascal (or a similar high-level language) is recommended for all readers, since it's used for most examples. Lisa Pascal is described in the documentation for the Lisa Pascal Workshop. What's in Each Volume Inside Macintosh consists of three volumes. Volume I begins with the following information of general interest: • a "road map" to the software and the rest of the documentation • the user interface guidelines •an introduction to memory management (the least you need to know, with a complete discussion following in Volume II) •some general information for assembly-language programmers It then describes the various parts of the User Interface Toolbox, the software in ROM that helps you implement the standard Macintosh user interface in your application. This is followed by descriptions of other, RAM-based software that's similar in function to the User Interface Toolbox. (The software overview in the Road Map chapter gives further details.) Volume II describes the Operating System, the software in ROM that does basic tasks such as input and output, memory management, and interrupt handling. As in Volume I, some functionally similar RAM-based software is then described. Volume III discusses your program's interface with the Finder and then describes the Macintosh 128K and 512K hardware. A comprehensive summary of all the software is provided, followed by some useful appendices and a glossary of all terms defined in Inside Macintosh. Version Numbers This edition of Inside Macintosh describes the following versions of the software: •version 105 of the ROM in the Macintosh 128K or 512K •version 112 of the ROM image installed by MacWorks in the Macintosh XL • version 1.1 of the Lisa Pascal interfaces and the assembly-language definitions Some of the RAM-based software is read from the file named System (usually kept in the System Folder). This manual describes the software in the System file whose creation date is May 2, 1984. A HORSE OF A DIFFERENT COLOR On an innovative system like the Macintosh, programs don't look quite the way they do on other systems. For example, instead of carrying out a sequence of steps in a predetermined order, your program is driven primarily by user actions (such as clicking and typing) whose order cannot be predicted. Il/4 About Inside Macintosh Preface You'll probably find that many of your preconceptions about how to write applications don't apply here. Because of this, and because of the sheer volume of information in Inside Macintosh, it's essential that you read the Road Map chapter. It will help you get oriented and figure out where to go next. THE STRUCTURE OF A TYPICAL CHAPTER Most chapters of Inside Macintosh have the same structure, as described below. Reading through this now will save you a lot of time and effort later on. It contains important hints on how to find what you're looking for within this vast amount of technical documentation. Every chapter begins with a very brief description of its subject and a list of what you should already know before reading that chapter. Then there's a section called, for example, "About the Window Manager", which gives you more information about the subject, telling you what you can do with it in general, elaborating on related user interface guidelines, and introducing terminology that will be used in the chapter. This is followed by a series of sections describing important related concepts and background information; unless they're noted to be for advanced programmers only, you'll have to read them in order to understand how to use the routines described later. Before the routine descriptions themselves, there's a section called, for example, "Using the Window Manager". It introduces you to the routines, telling you how they fit into the general flow of an application program and, most important, giving you an idea of which ones you'll need to use. Often you'll need only a few routines out of many to do basic operations; by reading this section, you can save yourself the trouble of learning routines you'll never use. Then, for the details about the routines, read on to the next section. It gives the calling sequence for each routine and describes all the parameters, effects, side effects, and so on. Following the routine descriptions, there may be some sections that won't be of interest to all readers. Usually these contain information about advanced techniques, or behind the scenes details for the curious. For review and quick reference, each chapter ends with a summary of the subject matter, including the entire Pascal interface and a separate section for assembly-language programmers. CONVENTIONS The following notations are used in Inside Macintosh to draw your attention to particular items of information: Note: A note that may be interesting or useful Warning: A point you need to be cautious about Assembly-language note: A note of interest to assembly-language programmers only Conventions 111-5 Inside Macintosh [Not in ROM] Routines marked with this notation are not part of the Macintosh ROM. Depending on how the interfaces have been set up on the development system you're using, these routines may or may not be available. They're available to users of Lisa Pascal; other users should check the documentation for their development system for more information. (For related information of interest to assembly-language programmers, see chapter 4 of Volume I.) III-6 Conventions 1 THE FINDER INTERFACE 9 About This Chapter 9 Signatures and File Types 10 Finder-Related Resources 10 Version Data 10 Icons and File References 11 Bundles 11 An Example 12 Formats of Finder-Related Resources Contents III-7 Inside Macintosh ///-8 The Finder I nteiface ABOUT THIS CHAPTER This chapter describes the interface between a Macintosh application program and the Finder. You should already be familiar with the details of the User Interface Toolbox and the Operating System. SIGNATURES AND FILE TYPES Every application must have a unique signature by which the Finder can identify it The signature can be any four-character sequence not being used for another application on any currently mounted volume (except that it can't be one of the standard resource types). To ensure uniqueness on all volumes, you must register your application's signature by writing to: Macintosh Technical Support Mail Stop 3-T Apple Computer, Inc. 20525 Mariani A venue Cupertino, CA 95014 Note: There's no need to register your own resource types, since they'll usually exist only in your own applications or documents. Signatures work together with tile types to enable the user to open or print a document (any file created by an application) from the Finder. When the application creates a file, it sets the file's creator and file type. Normally it sets the creator to its signature and the file type to a four- character sequence that identifies files of that type. When the user asks the Finder to open or print the file, the Finder starts up the application whose signature is the file's creator and passes the file type to the application along with other identifying information, such as the file name. (More information about this process is given in chapter 2 of Volume II.) An application may create its own special type or types of files. Like signatures, file types must be registered with Macintosh Technical Support to ensure uniqueness. When the user chooses Open from an application's File menu, the application will display (via the Standard File Package) the names of all files of a given type or types, regardless of which application created the files. Having a unique file type for your application's special files ensures that only the names of those files will be displayed for opening. Note: Signatures and file types may be strange, unreadable combinations of characters; they're never seen by end users of Macintosh. Applications may also create existing types of files. There might, for example, be an application that merges two MacWrite documents into a single document. In such cases, the application should use the same file type as the original application uses for those files. It should also specify the original application's signature as the file's creator; that way, when the user asks the Finder to open or print the file, the Finder will call on the original application to perform the operation. To learn the signature and file types used by an existing application, check with the application's manufacturer. Signatures and File Types Ill-9 Inside Macintosh Files that consist only of text-a stream of characters, with Return characters at the ends of paragraphs or short lines-should be given the standard file type TEXT'. This is the type that MacWrite gives to text only files it creates, for example. If your application uses this file type, its files will be accepted by MacWrite and it in turn will accept MacWrite text-only files (likewise for any other application that deals with TEXT' files, such as MacTerminal). Your application can give its own signature as the file's creator if it wants to be called to open or print the file when the user requests this from the Finder. For files that aren't to be opened or printed from the Finder, as may be the case for certain data files created by the application, the creator should be set to '????' (and the file type to whatever is appropriate). FINDER-RELATED RESOURCES To establish the proper interface with the Finder, every application's resource file must specify the signature of the application along with data that provides version information. In addition, there may be resources that provide information about icons and files related to the application. All of these Finder-related resources are described below, followed by a comprehensive example and (for interested programmers) the exact formats of the resources. Version Data Your application's resource file must contain a special resource that has the signature of the application as its resource type. This resource is called the version data of the application. The version data is typically a string that gives the name, version number, and date of the application, but it can in fact be any data at all. The resource ID of the version data is 0 by convention. Part of the process of installing an application on the Macintosh is to set the creator of the file that contains the application. You set the creator to the application's signature, and the Finder copies the corresponding version data into a resource file named Desktop. (The Finder doesn't display this file on the Macintosh desktop, to ensure that the user won't tamper with it.) Note: Additional, related resources may be copied into the Desktop file; see "Bundles" below for more information. Icons and File References For each application, the Finder needs to know: • the icon to be displayed for the application on the desktop, if different from the Finder's default icon for applications (see Figure 1) • if the application creates any files, the icon to be displayed for each type of file it creates, if different from the Finder's default icon for documents The Finder learns this information from resources called file references in the application's resource file. Each file reference contains a file type and an ID number, called a local ID, that identifies the icon to be displayed for that type of file. (The local ID is mapped to an actual resource ID as described under "Bundles" below.) Il/-10 Signatures and File Types The Finder Interface Application D Document Figure 1. The Finder's Default Icons The file type for the application itself is 'APPL'. This is the file type in the file reference that designates the application's icon. You also specify it as the application's file type at the same time that you specify its creator-when you install the application on the Macintosh. The ID number in a file ref~rence corresponds not to a single icon but to an icon list in the application's resource file. The icon list consists of two icons: the actual icon to be displayed on the desktop, and a mask consisting of that icon's outline filled with black (see Figure 2) . Icon •Mask Figure 2. Icon and Mask Bundles A bundle in the application's resource file groups together all the Finder-related resources. It specifies the following: • the application's signature and the resource ID of its version data • a mapping between the local IDs for icon lists (as specified in file references) and the actual resource IDs of the icon lists in the resource file • local IDs for the file references themselves and a mapping to their actual resource IDs When you install the application on the Macintosh, you set its "bundle bit"; the first time the Finder sees this, it copies the version data, bundle, icon lists, and file references from the application's resource file into the Desktop file. If there are any resource ID conflicts between the icon lists and file references in the application's resource file and those in Desktop, the Finder will change those resource IDs in Desktop. The Finder does this same resource copying and ID conflict resolution when you transfer an application to another volume. Note: The local IDs are needed only for use by the Finder. An Example Suppose you've written an application named SampWriter. The user can create a unique type of document from it, and you want a distinctive icon for both the application and its documents. The application's signature, as recorded with Macintosh Technical Support, is 'SAMP'; the file type assigned for its documents is 'SAMF'. You would include the following resources in the application's resource file: Finder-Related Resources Ill-11 Inside Macintosh Resource Resource ID Description Version data with 0 The string 'SampWriter Version 1--2/1/85' resource type 'SAMP' Icon list 128 The icon for the application The icon's mask Icon list 129 The icon for documents The icon's mask File reference 130 File type 'APPL' Local ID 0 for the icon list File reference 131 File type 'SAMF' Local ID 1 for the icon list Bundle 132 Signature 'SAMP' Resource ID 0 for the version data For icon lists, the mapping: local ID 0 ---7 resource ID 128 local ID 1 ---7 resource ID 129 For file references, the mapping: local ID 2 ---7 resource ID 130 local ID 3 ---7 resource ID 131 Note: See the documentation for the development system you're using for information about how to include these resources in a resource file. Formats of Finder-Related Resources The resource type for an application's version data is the signature of the application, and the resource ID is 0 by convention. The resource data can be anything at all; typically it's a string giving the name, version number, and date of the application. The resource type for an icon list is 'ICN#'. The resource data simply consists of the icons, 128 bytes each. The resource type for a file reference is 'FREF. The resource data has the format shown below. Number of bytes Contents 4 bytes File type 2 bytes Local ID for icon list The resource type for a bundle is 'BNDL'. The resource data has the format shown below. The format is more general than needed for Finder-related purposes because bundles will be used in other ways in the future. l//-12 Finder-Related Resources The Finder Jruerface Number of bytes Contents 4 bytes Signature of the application 2 bytes Resource ID of version data 2 bytes Number of resource types in bundle minus 1 For each resource type: 4 bytes Resource type 2 bytes Number of resources of this type minus 1 For each resource: 2 bytes Local ID 2 bytes Actual resource ID A bundle used for establishing the Finder interface contains the two resource types 'ICN#' and 'FREF'. Finder-Related Resources JJJ-13 Inside Macintosh l//-14 2 THE MACINTOSH HARDWARE 17 About This Chapter 17 Overview of the Hardware 18 The Video Interface 20 The Sound Generator 22 Diagram 22 The sec 25 Diagram 25 The Mouse 28 Diagram 29 The Keyboard and Keypad 30 Keyboard Communication Protocol 31 Keypad Communication Protocol 33 The Disk Interface 34 Controlling the Disk-State Control Lines 34 Reading from the Disk Registers 35 Writing to the Disk Registers 36 Explanations of the Disk Registers 36 The Real-Time Clock 37 Accessing the Clock Chip 38 The One-Second Interrupt 39 The VIA 39 VIA Register A 39 VIA Register B 40 The VIA Peripheral Control Register 40 The VIA Timers 41 VIA Interrupts 42 Other VIA Registers 42 System Startup 43 Summary Contents Ill-15 Inside Macintosh III-16 The Maciruosh Hardware ABOUT THIS CHAPTER This chapter provides a basic description of the hardware of the Macintosh 128K and 512K computers. It gives you information that you'll need to connect other devices to the Macintosh and to write device drivers or other low-level programs. It will help you figure out which technical documents you'll need to design peripherals; in some cases, you'll have to obtain detailed specifications from the manufacturers of the various interface chips. - This chapter is oriented toward assembly-language programmers. It assumes you're familiar with the basic operation of microprocessor-based devices. Knowledge of the Macintosh Operating System will also be helpful. Warning: Only the Macintosh 128K and 512K are covered in this chapter. In particular, note that the memory addresses and screen size are different on the Macintosh XL (and may be different in future versions of the Macintosh). To maintain software compatibility across the Macintosh line, and to allow for future changes to the hardware, you're strongly advised to use the Toolbox and Operating System routines wherever possible. To learn how your program can determine which hardware environment it's operating in, see the description of the Environs procedure in chapter 13 of Volume II. OVERVIEW OF THE HARDWARE The Macintosh computer contains a Motorola MC68000 microprocessor clocked at 7.8336 megahertz, random access memory (RAM), read-only memory (ROM), and several chips that enable it to communicate with external devices. There are five I/O devices: the video display; the sound generator; a Synertek SY6522 Versatile Interface Adapter (VIA) for the mouse and keyboard; a Zilog Z8530 Serial Communications Controller (SCC) for serial communication; and an Apple custom chip, called the IWM ("Integrated Woz Machine") for disk control. The Macintosh uses memory-mapped 1/0, which means that each device in the system is accessed by reading or writing to specific locations in the address space of the computer. Each device contains logic that recognizes when it's being accessed and responds in the appropriate manner. The MC68000 can directly access 16 megabytes (Mb) of address space. In the Macintosh, this is divided into four equal sections. The first four Mb are for RAM, the second four Mb are for ROM, the third are for the SCC, and the last four are for the IWM and the VIA. Since each of the devices within the blocks has far fewer than four Mb of individually addressable locations or registers, the addresses within each block "wrap around" and are. repeated several times within the block. RAM is the "working memory" of the system. Its base address is address 0. The first 256 bytes of RAM (addresses 0 through $FF) are used by the MC68000 as exception vectors; these are the addresses of the routines that gain control when~ver an exception such as an interrupt or a trap occurs. (The summary at the end of this chapter includes a list of all the exception vectors.) RAM also contains the system and application heaps, the stack, and other information used by applications. In addition, the following hardware devices share the use of RAM with the MC68000: Overview of the Hardware III-17 Inside Macintosh •the video display, which reads the infonnation for the display from one of two screen buffers • the sound generator, which reads its infonnation from one of two sound buffers • the disk speed controller, which shares its data space with the sound buffers The MC68000 accesses to RAM are interleaved (alternated) with the video display's accesses during the active portion of a screen scan line (video scanning is described in the next section). The sound generator and disk speed controller are given the first access after each scan line. At all other times, the MC68000 has unintenupted access to RAM, increasing the average RAM access rate to about 6 megahertz (MHz). ROM is the system's pennanent read-only memory. Its base address, $400000, is available as the constant romStart and is also stored in the global variable ROMBase. ROM contains the routines for the Toolbox and Operating System, and the various system traps. Since the ROM is used exclusively by the MC68000, it's always accessed at the full processor rate of 7.83 MHz. The address space reserved for the device 1/0 contains blocks devoted to each of the devices within the computer. This region begins at address $800000 and continues to the highest address at $FFFFFF. Note: Since the VIA is involved in some way in almost every operation of the Macintosh, the following sections frequently refer to the VIA and VIA-related constants. The VIA itself is described later, and all the constants are listed in the summary at the end of this chapter. THE VIDEO INTERFACE The video display is created by a moving electron beam that scans across the screen, turning on and off as it scans in order to create black and white pixels. Each pixel is a square, approximately 1174 inch on a side. To create a screen image, the electron beam starts at the top left comer of the screen (see Figure 1). The beam scans horizontally across the screen from left to right, creating the top line of graphics. When it reaches the last pixel on the right end of the top line it turns off, and continues past the last pixel to the physical right edge of the screen. Then it flicks invisibly back to the left edge and moves down one scan line. After tracing across the black border, it begins displaying the data in the second scan line. The time between the display of the rightmost pixel on one line and the leftmost pixel on the next is called the horizontal blanking interval. When the electron beam reaches the last pixel of the last (342nd) line on the screen, it traces out to the right edge and then flicks up to the top left corner, where it traces the left border and then begins once again to display the top line. The time between the last pixel on the bottom line and the first one on the top line is called the vertical blanking interval. At the beginning of the vertical blanking interval, the VIA generates a vertical blanking interrupt. The pixel clock rate (the frequency at which pixels are displayed) is 15.6672 MHz, or about .064 microseconds (µsec) per pixel. For each scan line, 512 pixels are drawn on the screen, requiring 32.68 µsec . The horizontal blanking interval takes the time of an additional 192 pixels, or 12.25 µsec . Thus, each full scan line takes 44.93 µsec, which means the horizontal scan rate is 22.25 kilohertz. III-18 Over-view of the Hardware The Macintosh Hardware horizontal horizontal vertical blanking Iblanking ends blanking startsl there here ends here black border vertical blanking starts here 512 pixels wide Figure 1. Video Scanning Pattern A full screen display consists of 342 horizontal scan lines, occupying 15367 .65 µsec, or about 15.37 milliseconds (msec). The vertical blanking interval takes the time of an additional 28 scan lines-1258.17 µsec, or about 1.26 msec. This means the full screen is redisplayed once every 16625.8 µsec. That's about 16.6 msec per frame, which means the vertical scan rate (the full screen display frequency) is 60.15 hertz. The video generator uses 21,888 bytes of RAM to compose a bit-mapped video image 512 pixels wide by 342 pixels tall. Each bit in this range controls a single pixel in the image: A 0 bit is white, and a 1 bit is black. There are two screen buffers (areas of memory from which the video circuitry can read information to create a screen display): the main buffer and the alternate buffer. The starting addresses of the screen buffers depend on how much memory you have in your Macintosh. In a Macintosh 128K, the main screen buffer starts at $1A700 and the alternate buffer starts at $12700; for a 512K Macintosh, add $60000 to these numbers. Warning: To be sure you don't use the wrong area of memory and to maintain compatibility with future Macintosh systems, you should get the video base address and bit map dimensions from screenBits (see chapter 6 of Volume I). Each scan line of the screen displays the contents of 32 consecutive words of memory, each word controlling 16 horizontally adjacent pixels. In each word, the high-order bit (bit 15) controls the leftmost pixel and the low-order bit (bit 0) controls the rightmost pixel. The first word in each scan line follows the last word on the line above it. The starting address of the screen is thus in The Video Interface III-19 Inside Macintosh the top left comer, and the addresses progress from there to the right and down, to the last byte in the extreme bottom right corner. Normally, the video display doesn't flicker when you read from or write to it, because the video memory accesses are interleaved with the processor accesses. But if you're creating an animated image by repeatedly drawing the graphics in quick succession, it may appear to flicker if the electron beam displays it when your program hasn't finished updating it, showing some of the new image and some of the old in the same frame. One way to prevent flickering when you're updating the screen continuously is to use the vertical and horizontal blanking signals to synchronize your updates to the scanning of video memory. Small changes to your screen can be completed entirely during the interval between frames (the first 1.26 msec following a vertical blanking interrupt), when nothing is being displayed on the screen. When making larger changes, the trick is to keep your changes happening always ahead of the spot being displayed by the electron beam, as it scans byte by byte through the video memory. Changes you make in the memory already passed over by the scan spot won't appear until the next frame. If you start changing your image when the vertical blanking interrupt occurs, you have 1.26 msec of unrestricted access to the image. After that, you can change progressively less and less of your image as it's scanned onto the screen, starting from the top (the lowest video memory address). From vertical blanking interrupt, you have only 1.26 msec in which to change the first (lowest address) screen location, but you have almost 16.6 msec to change the last (highest address) screen location. Another way to create smooth, flicker-free graphics, especially useful with changes that may take more 16.6 msec, is to use the two screen buffers as alternate displays. If you draw into the one that's currently not being displayed, and then switch the buffers during the next vertical blanking, your graphics will change all at' once, producing a clean animation. (See chapter 11 of Volume II to find out how to specify tasks to be performed during vertical blanking.) If you want to use the alternate screen buffer, you'll have to specify this to the Segment Loader (see chapter 2 of Volume II for details). To switch to the alternate screen buffer, clear the following bit of VIA data register A (vBase+vBufA): vPage2 .EQU 6 ;O = a lternate screen buffer For example: BCLR #vPage2,vBase+vBufA To switch back to the main buffer, set the same bit. Warning: Whenever you change a bit in a VIA data register, be sure to leave the other bits in the register unchanged. Warning: The alternate screen buffer may not be supported in future versions of the Macintosh. THE SOUND GENERATOR The Macintosh sound circuitry uses a series of values taken from an area of RAM to create a changing waveform in the output signal. This signal drives a small speaker inside the Macintosh III-20 The Video Interface The Macintosh Hardware and is connected to the external sound jack on the back of the computer. If a plug is inserted into the external sound jack, the internal speaker is disabled. The external sound line can drive a load of 600 or more ohms, such as the input of almost any audio amplifier, but not a directly connected external speaker. The sound generator may be turned on or off by writing 1 (off) or 0 (on) to the following bit of VIA data register B (vBase+vBufB): vSndEnb .EQU 7 ;O sound enabled, 1 = disabled For example: BSET #vSndEnb,vBase+vBufB ;turn off sound By storing a range of values in the sound buffer, you can create the corresponding waveform in the sound channel. The sound generator uses a form of pulse-width encoding to create sounds. The sound circuitry reads one word in the sound buffer during each horizontal blanking interval (including the "virtual" intervals during vertical blanking) and uses the high-order byte of the word to generate a pulse of electricity whose duration (width) is proportional to the value in the byte. Another circuit converts this pulse into a voltage that's attenuated (reduced) by a three-bit value from the VIA. This reduction corresponds to the current setting of the volume level. To set the volume directly, store a three-bit number in the low-order bits of VIA data register A (vBase+vBufA). You can use the following constant to isolate the bits involved: vSound . EQU 7 ;sound volume bits Here's an example of how to set the sound level: MOVE .B vBase+vBufA,DO ;get current value of register A ANDI.B #255-vSound,DO ;clear the sound bits ORI.B #3,DO ;set medium sound level MOVE.B DO,vBase+vBufA ;put the data back After attenuation, the sound signal is passed to the audio output line. The sound circuitry scans the sound buffer at a fixed rate of 370 words per video frame, repeating the full cycle 60.15 times per second. To create sounds with frequencies other than multiples of the basic scan rate, you must store phase-shifted patterns into the sound buffer between each scan. You can use the vertical and horizontal blanking signals (available in the VIA) to synchronize your sound buffer updates to the buffer scan. You may find that it's much easier to use the routines in the Sound Driver to do these functions. Warning: The low-order byte of each word in the sound buffer is used to control the speed of the motor in the disk drive. Don't store any information there, or you'll interfere with the disk 110. There are two sound buffers, just as there are two screen buffers. The address of the main sound buffer is stored in the global variable SoundBase and is also available as the constant soundLow. The main sound buffer is at $1FDOO in a 128K Macintosh, and the alternate buffer is at $1Al00; for a 512K Macintosh, add $60000 to these values. Each sound buffer contains 370 words of data. As when you want to use the alternate screen buffer, you'll have to specify to the Segment Loader that you want the alternate buffer (see chapter 2 of Volume II for details). To select the alternate sound buffer for output, clear the following bit of VIA data register A (vBase+vBufA): The Sound Generator Ill-21 Inside Macintosh vSndPg2 . EQU 3 ;0 = alternate sound buffer To return to the main buffer, set the same bit. Warning: Be sure to switch back to the main sound buffer before doing a disk access, or the disk won't work properly. Warning: The alternate sound buffer may not be supported in future versions of the Macintosh. There's another way to generate a simple, square-wave tone of any frequency, using almost no processor intervention. To do this, first load a constant value into all 370 sound buffer locations (use $00's for minumum volume, $FFs for maximum volume). Next, load a value into the VIA's timer 1 latches, and set the high-order two bits of the VIA's auxiliary control register (vBase+vACR) for "square wave output" from timer 1. The timer will then count down from the latched value at 1.2766 µsecJcount, over and over, inverting the vSndEnb bit of VIA register B (vBase+vBuffi) after each count down. This takes the constant voltage being generated from the sound buffer and turns it on and off, creating a square-wave sound whose period is 2 * 1.2766 µsec * timer l's latched value Note: You may want to disable timer 1 interrupts during this process (bit 6 in the VIA's interrupt enable register, which is at vBase+vIER). To stop the square-wave sound, reset the high-order two bits of the auxiliary control register. Note: See the SY6522 technical specifications for details of the VIA registers. See also "Sound Driver Hardware" in chapter 8 of Volume II. Diagram Figure 2 shows a block diagram for the sound port THE sec The two serial ports are controlled by a Zilog Z8530 Serial Communications Controller (SCC). The port known as SCC port A is the one with the modem icon on the back of the Macintosh. SCC port B is the one with the printer icon. Macintosh serial ports conform to the EIA standard RS422, which differs from the more common RS232C standard. While RS232C modulates a signal with respect to a common ground ("single- ended" transmission), RS422 modulates two signals against each other ("differential" transmission). The RS232C receiver senses whether the received signal is sufficiently negative with respect to ground to be a logic "l", whereas the RS422 receiver simply senses which line is more negative than the other. This makes RS422 more immune to noise and interference, and more versatile over longer distances. If you ground the positive side of each RS422 receiver and leave unconnected the positive side of each transmitter, you've converted to EIA standard RS423, which can be used to communicate with most RS232C devices over distances up to fifty feet or so. III-22 The Sound Generator The Macintosh Hardware Sound output connector 0 d' ··· ... -------, Internal speaker (disconnected when sound output _ _ _ _ _ __,l ___ --2 connecter is used) 6522 (VIA) PAOl---_.r.V7o71u_m_e_c_on~t~ro"""'."11 Sound/ disk-speed buffer (in RAM) Alternate PA1 i----~ (eight levels) PA2r---+L~:::..:..=.....:.:..:.::.:.;.~ buffer PA3 High Low (even) (odd) byte byte Sound On-off switch - >. 41) .._ n ~ ::J 0 O !sound 1 (Sound 2 (Sound Di sk I~ ......, Di sk I~· ·· ·. .\. Di sk I~ ......\-.. PB7 (timer 1) reset (square-wave generator) 41) (\') CJ) 3 !s ound Di sk k ··... .. . : }: :-,_ ... - "O - ·... . -- 1 (Sound Disk I~· .. I _, I I 1 1 SF (Sound Di sk I .. To motor speed control 170 (Sound Di sk 1-i· ·..··./ I ines for internal end 171 (Sound Di sk I~ · · · .·· external di sk drives Figure 2. Diagram of Sound Port The sec 111-21 Inside Macintosh The serial inputs and outputs of the SCC are connected to the ports through differential line drivers (26LS30) and receivers (26LS32). The line drivers can be put in high-impedance mode between transmissions, to allow other devices to transmit over those lines. A driver is activated by lowering the SCC's Request To Send (RTS) output for that port. Port A and port B are identical except that port A (the modem port) has a higher interrupt priority, making it more suitable for high-speed communication. Figure 3 shows the DB-9 pinout for the SCC output jacks. 4 3 2 ••• 9 8 7 6 •••• 1 Ground 2 +5 volts 3 Ground 4 Transmit data + 5 Transmit data - 6 + 12 volts 7 Handshake/external clock 8 Receive data + 9 Receive data - Figure 3. Pinout for SCC Output Jacks Warning: Do not draw more than 100 milliamps at +12 volts, and 200 milliamps at +5 volts from all connectors combined. Each port's input-only handshake line (pin 7) is connected to the SCC's Clear To Send (CTS) input for that port, and is designed to accept an external device's Data Terminal Ready (DTR) handshake signal. This line is also connected to the SCC's external synchronous clock (TRxC) input for that port, so that an external device can perform high-speed synchronous data exchange. Note that you can't use the line for receiving DTR if you're using it to receive a high-speed data clock. The handshake line is sensed by the Macintosh using the positive (noninverting) input of one of the standard RS422 receivers (26LS32 chip), with the negative input grounded. The positive input was chosen because this configuration is more immune to noise when no active device is connected to pin 7. Note: Because this is a differential receiver, any handshake or clock signal driving it must be "bi-polar", alternating between a positive voltage and a negative voltage, with respect to the internally grounded negative input. If a device tries to use ground (0 volts) as one of its handshake logic levels, the Macintosh will receive that level as an indeterminate state, with unpredictable results. III-24 The sec The Macintosh Hardware The sec itself (at its PCLK pin) is clocked at 3.672 megahertz. The internal synchronous clock (RTxC) pins for both ports are also connected to this 3.672 MHz clock. This is the clock that, after dividing by 16, is normally fed to the SeC's internal baud-rate generator. The sec chip generates level-1 processor interrupts during 110 over the serial lines. For more information about SeC interrupts, see chapter 6 of Volume II. The locations of the SCC control and data lines are given in the following table as offsets from the constant sccWBase for writes, or sccRBase for reads. These base addresses are also available in the global variables SCCWr and SCCRd. The SCC is on the upper byte of the data bus, so y0u must use only even-addressed byte reads (a byte read of an odd SCC read address tries to reset the entire SCC). When writing, however, you must use only odd-addressed byte writes (the MC68000 puts your data on both bytes of the bus, so it works correctly). A word access to any sec address will shift the phase of the computer's high-frequency timing by 128 nanoseconds (system software adjusts it correctly during the system startup process). Location Contents sccWBase+aData Write data register A sccRBase+aData Read data register A secWBase+bData Write data register B sccRB ase+bData Read data register B secWB ase+aCtl Write control register A sccRB ase+aCtl Read control register A sccWBase+bCtl Write control register B sccRBase+bCtl Read control register B Warning: Don't access the SCC chip more often than once every 2.2 µsec. The SCC requires that much time to let its internal lines stabilize. Refer to the technical specifications of the Zilog Z8530 for the detailed bit maps and control methods (baud rates, protocols, and so on) of the sec. Diagram Figure 4 shows a circuit diagram for the serial ports. THE MOUSE The DB-9 connector labeled with the mouse icon connects to the Apple mouse (Apple II, Apple III, Lisa, and Macintosh mice are electrically identical). The mouse generates four square- wave signals that describe the amount and direction of the mouse's travel. Interrupt-driven routines in the Macintosh ROM convert this information into the corresponding motion of the pointer on the screen. By turning an option called mouse scaling on or off in the Control Panel desk accessory, the user can change the amount of screen pointer motion that corresponds to a The Mouse 111-25 Inside Macintosh 8530 (SCC) TxDA Op,+ RfI f1 lter TXD+ ~ Op,- TXD- +5V -=- RTSA RfI f 1lter >--- -- - - - , TxDB Io Oo+ Rf I f 1lter OED Oo - RTSB Slew-rate +12V +5v 'k:c control3 -5V \!E Mode -=- 26LS32 OA RXD - RXDA Rf I f 1lter RXD+ Rflf1lter CTSA Oc TRxCA HSK/CLK RfI f1 lter 09 Rfl fl lter RxDB Rf I f 1I ter CTSB Oo TXD+ TRxCB TXD- +sv -=- RfI f 1lter 6522 (VIA) PA7 RXD- +12V RXD+ 3.672 MHz HSK/CLK R1 R2 Note:~=~ I R1 + R2 = 40 to 60 ohm3 C = 150 to 300 pf Figure 4. Diagram of Serial Ports III-26 The Mouse The Macintosh Hardware given mouse motion, depending on how fast the mouse is moved; for more information about mouse scaling, see the discussion of parameter RAM in chapter 13 of Volume II. Note: The mouse is a relative-motion device; that is, it doesn't report where it is, only how far and in which direction it's moving. So if you want to connect graphics tablets, touch screens, light pens, or other absolute-position devices to the mouse port, you must either convert their coordinates into motion information or install your own device-handling routines. The mouse operates by sending square-wave trains of information to the Macintosh that change as the velocity and direction of motion change. The rubber-coated steel ball in the mouse contacts two capstans, each connected to an interrupter wheel: Motion along the mouse's X axis rotates one of the wheels and motion along the Y axis rotates the other wheel. The Macintosh uses a scheme known as quadrature to detect which direction the mouse is moving along each axis. There's a row of slots on an interrupter wheel, and two beams of infrared light shine through the slots, each one aimed at a phototransistor detector. The detectors are offset just enough so that, as the wheel turns, they produce two square-wave signals (called the interrupt signal and the quadrature signal) 90 degrees out of phase. The quadrature signal precedes the interrupt signal by 90 degrees when the wheel turns one way, and trails it when the wheel turns the other way. The interrupt signals, Xl and Yl, are connected to the SCC's DCDA and DCDB inputs, respectively, while the quadrature signals, X2 and Y2, go to inputs of the VIA's data register B. When the Macintosh is interrupted (from the SCC) by the rising edge of a mouse interrupt signal, it checks the VIA for the state of the quadrature signal for that axis: If it's low, the mouse is moving to the left (or down), and if it's high, the mouse is moving to the right (or up). When the sec interrupts on the falling edge, a high quadrature level indicates motion to the left (or down) and a low quadrature level indicates motion to the right (or up): sec VIA Mouse Mouse interrupt Mouse quadrature Motion direction in XI (or Yl) X2 (or Y2) X (or Y) axis Positive edge Low Left (or down) High Right (or up) Negative edge Low Right (or up) High Left (or down) Figure 5 shows the interrupt (YI) and quadrature (Y2) signals when the mouse is moved downwards. The switch on the mouse is a pushbutton that grounds pin 7 on the mouse connector when pressed. The state of the button is checked by software during each vertical blanking interrupt. The small delay between each check is sufficient to debounce the button. You can look directly at the mouse button's state by examining the following bit of VIA data register B (vBase+vBufB): vSW .EQU 3 ;O = mouse button is down If the bit is clear, the mouse button is down. However, it's recommended that you let the Operating System handle this for you through the event mechanism. Figure 6 shows the DB-9 pinout for the mouse jack at the back of the Macintosh. The Mouse Ill-27 Inside Macintosh I positive- edge interrupt I I negative-edge interrupt v1JlJl_JL_ I ' I I Y2 ___Il_j_fl__fl_ quadrature motion levels interrupts VIA sec Date reg.B YZ bit 5 y 1 DCD B ~--------x-2-1bit 4 X1 DCD A X1 Figure 5. Mouse Mechanism 4 3 2 ••• 9 8 7 6 •••• 1 Ground 2 +5 volts 3 Ground 4 Mouse X2 (VIA quadrature signal) 5 Mouse X1 (SCC interrupt si gna I) 6 (not connected) 7 Mouse switch 8 Mouse Y2 (VIA quadrature signal) 9 Mouse Y1 (SCC interrupt s i gne I) Figure 6. Pinout for Mouse Jack Warning: Do not draw more than 200 milliamps at +5 volts from all connectors combined. Diagram Figure 7 shows a circuit diagram for the mouse port III-28 The Mouse The Macintosh Hardware 6522 (VIA) Switch PB3 RFI Filter PB4 X2 RFI F1 lter X2 CI) X1 +SV ":" RFI Filter 3 2 27 27 Y2 ohms ohms Y2 PBS Switch ":" 8530 (SCC) X1 DCDA 27 27 ohms ohms DCD9 Y1 Y1 ":" R1 R2 Note: ~ I R1 + R2 = 40 to 60 ohms C = 150 to 300 pf Figure 7. Diagram of Mouse Port THE KEYBOARD AND KEYPAD The Macintosh keyboard and numeric keypad each contain an Intel 8021 microprocessor that scans the keys. The 8021 contains ROM and RAM, and is programmed to conform to the interface protocol described below. The keyboard plugs into the Macintosh through a four-wire RJ-11 telephone-style jack. If a numeric keypad is installed in the system, the keyboard plugs into it and it in turn plugs into the The Keyboard and Keypad III-29 Inside Macintosh Macintosh. Figure 8 shows the pinout for the keyboard jack on the Macintosh, on the keyboard itself, and on the numeric keypad. 1 Ground 2 Clock 3 Data 4 +5 volts Figure 8. Pinout for Keyboard Jack Warning: Do not draw more than 200 milliamps at +5 volts from all connectors combined. Keyboard Communication Protocol The keyboard data line is bidirectional and is driven by whatever device is sending data. The keyboard clock line is driven by the keyboard only. All data transfers are synchronous with the keyboard clock. Each transmission consists of eight bits, with the highest-order bits first. When sending data to the Macintosh, the keyboard clock transmits eight 330-µsec cycles (160 µsec low, 170 µsec high) on the normally high clock line. It places the data bit on the data line 40 µsec before the falling edge of the clock line and maintains it for 330 µsec. The data bit is clocked into the Macintosh's VIA shift register on the rising edge of the keyboard clock cycle. When the Macintosh sends data to the keyboard, the keyboard clock transmits eight 400-µsec cycles (180 µsec low, 220 µsec high) on the clock line. On the falling edge of the keyboard clock cycle, the Macintosh places the data bit on the data line and holds it there for 400 µsec. The keyboard reads the data bit 80 µsec after the rising edge of the keyboard clock cycle. Only the Macintosh can initiate communication over the keyboard lines. On power-up of either the Macintosh or the keyboard, the Macintosh is in charge, and the external device is passive. The Macintosh signals that it's ready to begin communication by pulling the keyboard data line low. Upon detecting this, the keyboard starts clocking and the Macintosh sends a command. The last bit of the command leaves the keyboard data line low; the Macintosh then indicates it's ready to receive the keyboard's response by setting the data line high. The first command the Macintosh sends out is the Model Number command. The keyboard's response to this command is to reset itself and send back its model number to the Macintosh. If no response is received for 112 second, the Macintosh tries the Model Number command again. Once the Macintosh has successfully received a model number from the keyboard, normal ll/-30 The Keyboard and Keypad The Macintosh Hardware operation can begin. The Macintosh sends the Inquiry command; the keyboard sends back a Key Transition response if a key has been pressed or released. If no key transition has occurred after 1/4 second, the keyboard sends back a Null response to let the Macintosh know it's still there. The Macintosh then sends the Inquiry command again. In normal operation, the Macintosh sends out an Inquiry command every 1/4 second. If it receives no response within 1/2 second, it assumes the keyboard is missing or needs resetting, so it begins again with the Model Number command. There are two other commands the Macintosh can send: the Instant command, which gets an instant keyboard status without the 1/4-second timeout, and the Test command, to perform a keyboard self-test. Here's a list of the commands that can be sent from the Macintosh to the keyboard: Command name Value Keyboard response Inquiry $10 Key Transition code or Null ($7B) Instant $14 Key Transition code or Null ($7B) Model Number $16 Bit 0: 1 Bits 1-3: keyboard model number, 1-8 Bits 4-6: next device number, 1-8 Bit 7: 1 if another device connected Test $36 ACK ($7D) or NAK ($77) The Key Transition responses are sent out by the keyboard as a single byte: Bit 7 high means a key-up transition, and bit 7 low means a key-down. Bit 0 is always high. The Key Transition responses for key-down transitions on the keyboard are shown (in hexadecimal) in Figure 9. Note that these response codes are different from the key codes returned by the keyboard driver software. The keyboard driver strips off bit 7 of the response and shifts the result one bit to the right, removing bit 0. For example, response code $33 becomes $19, and $2B becomes $15. Keypad Communication Protocol When a numeric keypad is used, it must be inserted between the keyboard and the Macintosh; that is, the keypad cable plugs into the jack on the front of the Macintosh, and the keyboard cable plugs into a jack on the numeric keypad. In this configuration, the timings and protocol for the clock and data lines work a little differently: The keypad acts like a keyboard when communicating with the Macintosh, and acts like a Macintosh when communicating over the separate clock and data lines going to the keyboard. All commands from the Macintosh are now received by the keypad instead of the keyboard, and only the keypad can communicate directly with the keyboard. When the Macintosh sends out an Inquiry command, one of two things may happen, depending on the state of the keypad. If no key transitions have occurred on the keypad since the last Inquiry, the keypad sends an Inquiry command to the keyboard and, later, retransmits the keyboard's response back to the Macintosh. But if a key transition has occurred on the keypad, the keypad responds to an Inquiry by sending back the Keypad response ($79) to the Macintosh. In that case, the Macintosh immediately sends an Instant command, and this time the keypad sends back its own Key Transition response. As with the keyboard, bit 7 high means key-up and bit 7 low means key-down. The Keyboard and Keypad III-31 Inside Macintosh ' 65 Tab 61 Cops Lock A S D F G H J K Return 73 01 03 05 07 OB 09 4D 51 49 Shift 71 space 63 U.S. keyboard § +- 65 67 -+I 61 ~ A s D F G H J K L ' 73 01 03 05 07 OB 09 4D 51 4B 53 4F 49 55 ~ \ z c v B N I 71 OD OF 13 17 SB SD 1S 71 --.:: ~ space -,,...- --.:: 75 6F 69 63 75 International keyboard (Greet Britain key caps shown) Clear - BJ IE OF 10 OD 05 7 8 9 ~ 33 37 39 1B 4 5 6 l!J 2D 2F 31 11 1 2 3 Enter 27 29 2B 0 . 25 03 19 Keypad (U.S. key caps shown) Figure 9. Key-Down Transitions The Key Transition responses for key-down transitions on the keypad are shown in Figure 9. Again, note that these response codes are different from the key codes returned by the keyboard driver software. The keyboard driver strips off bit 7 of the response and shifts the result one bit to the right, removing bit 0. 111-32 The Keyboard and Keypad The Macintosh Hardware THE DISK INTERFACE The Macintosh disk interface uses a design similar to that used on the Apple II and Apple III computers, employing the Apple custom IWM chip. Another custom chip called the Analog Signal Generator (ASG) reads the disk speed buffer in RAM and generates voltages that control the disk speed. Together with the VIA, the IWM and the ASG generate all the signals necessary to read, write, format, and eject the 3 1/2-inch disks used by the Macintosh. The IWM controls four of the disk state-control lines (called CAO, CAI, CA2, and LSTRB), chooses which drive (internal or external) to enable, and processes the disk's read-data and write- data signals. The VIA provides another disk state-control line called SEL. A buffer in RAM (actually the low-order bytes of words in the sound buffer) is read by the ASG to generate a pulse-width modulated signal that's used to control the speed of the disk motor. The Macintosh Operating System uses this speed control to allow it to store more sectors of information in the tracks closer to the edge of the disk by running the disk motor at slower speeds. Figure 10 shows the DB-19 pinout for the external disk jack at the back of the Macintosh. 9 8 7 6 54 32 •••••••• 19 18 17 16 15 14 13 12 11 ••••••••• 1 Ground 11 CAO 2 Ground 12 CA1 3 Ground 13 CA2 4 Ground 14 LSTRB 5 -12 volts 15 Write reque3t 6 +5 volts 16 SEL 7 + 12 volts 17 External drive enable 8 +12volts 18 Read data 9 (not connected) 19 Write data 1O Motor 3peed contra I Figure 10. Pinout for Disk Jack Warning: This connector was designed for a Macintosh 3 1/2-inch disk drive, which represents a load of 500 milliamps at +12 volts, 500 milliamps at +5 volts, and 0 milliamps at-12 volts. If any other device uses this connector, it must not exceed these loads by more than 100 milliamps at +12 volts, 200 milliamps at +5 volts, and 10 milliamps at-12 volts, including loads from all other connectors combined. The Disk Interface III-33 Inside Macintosh Controlling the Disk State-Control Lines The IWM contains registers that can be used by the software to control the state-control lines leading out to the disk. By reading or writing certain memory locations, you can tum these state- control lines on or off. Other locations set various IWM internal states. The locations are given in the following table as offsets from the constant dBase, the base address of the IWM; this base address is also available in a global variable named IWM. The IWM i~ on the lower byte of the data bus, so use odd-addressed byte accesses only. · Location to Location to IWM line turn line on turn line off Disk state-control lines: CAO dBase+phOH dBase+phOL CAI dBase+phlH dBase+phlL CA2 dBase+ph2H dBase+ph2L LSTRB dBase+ph3H dBase+ph3L Disk enable line: ENABLE dBase+motorOn dBase+motorOff IWM internal states: SELECT dBase+extDrive dBase+intDrive Q6 dBase+q6H dBase+q6L Q7 dBase+q7H dBase+q7L To tum one of the lines on or off, do any kind of memory byte access (read or write) to the respective location. The CAO, CAl, and CA2 lines are used along with the SEL line from the VIA to select from among the registers and data signals in the disk drive. The LSfRB line is used when writing control information to the disk registers (as described below), and the ENABLE line enables the selected disk drive. SELECT is an IWM internal line that chooses which disk drive can be enabled: On selects the external drive, and off selects the internal drive. The Q6 and Q7 lines are used to set up the internal state of the IWM for reading disk register information, as well as for reading or writing actual disk-storage data. You can read information from several registers in the disk drive to find out whether the disk is locked, whether a disk is in the drive, whether the head is at track 0, how many heads the drive has, and whether there's a drive connected at all. In tum, you can write to some of these registers to step the head, turn the motor on or off, and eject the disk. Reading from the Disk Registers Before you can read from any of the disk registers, you must set up the state of the IWM so that it can pass the data through to the MC68000's memory space where you'll be able to read it. To do that, you must first tum off Q7 by reading or writing dBase+q7L. Then tum on Q6 by accessing dBase+q6H. After that, the IWM will be able to pass data from the disk's RD/SENSE line through to you. ///-34 The Disk Interface The Macintosh Hardware Once you've set up the IWM for disk register access, you must next select which register you want to read. To read one of the disk registers, first enable the drive you want to use (by accessing dBase+intDrive or dBase+extDrive and then dBase+rnotorOn) and make sure LSTRB is low. Then set CAO, CAI, CA2, and SEL to address the register you want. Once this is done, you can read the disk register data bit in the high-order bit of dBase+q7L. After you've read the data, you may read another disk register by again setting the proper values in CAO, CAl, CA2, and SEL, and then reading dBase+q7L. Warning: When you're finished reading data from the disk registers, it's important to leave the IWM in a state that the Disk Driver will recognize. To be sure it's in a valid logic state, always tum Q6 back off (by accessing dBase+q6L) after you've finished reading the disk registers. The following table shows how you must set the disk state-control lines to read from the various disk registers and data signals: State-control lines Register CA2 CAl CAO SEL addressed Information in register 0 0 0 0 DffiTN Head step direction 0 0 0 1 CSTIN Disk in place 0 0 1 0 STEP Disk head stepping 0 0 1 1 WRTPRT Disk locked 0 1 0 0 MOfORON Disk motor running 0 1 0 1 TKO Head at track 0 0 1 1 1 TACH Tachometer 1 0 0 0 RDDATAO Read data, lower head 1 0 0 1 RDDATAl Read data, upper head 1 1 0 0 SIDES Single- or double-sided drive 1 1 1 1 DRVIN Drive installed Writing to the Disk Registers To write to a disk register, first be sure that LSTRB is off, then tum on CAO and CAL Next, set SEL to 0. Set CAO and CAl to the proper values from the table below, then set CA2 to the value you want to write to the disk register. Hold LSTRB high for at least one µsec but not more than one msec (unless you're ejecting a disk) and bring it low again. Be sure that you don't change CAO-CA2 or SEL while LSTRB is high, and that CAO and CAl are set high before changing SEL. The following table shows how you must set the disk state-control lines to write to the various disk registers: Control lines Register CAl CAO SEL addressed Register function 0 0 0 DIRTN Set stepping direction 0 1 0 STEP Step disk head one track 1 0 0 MOTORON Tum on/off disk motor 1 1 0 EJECT Eject the disk The Disk Interface /II-35 Inside Macintosh Explanations of the Disk Registers The information written to or read from the various disk registers can be interpreted as follows: • The DIRTN signal sets the direction of subsequent head stepping: 0 causes steps to go toward the inside track (track 79), 1 causes them to go toward the outside track (track 0). • CSTIN is 0 only when a disk is in the drive. • Setting STEP to 0 steps the head one full track in the direction last set by DIRTN. When the step is complete (about 12 msec), the disk drive sets STEP back to 1, and then you can step again. • WRTPRT is 0 whenever the disk is locked. Do not write to a disk unless WRTPRT is 1. • MOTORON controls the state of the disk motor: 0 turns on the motor, and 1 turns it off. The motor will run only if the drive is enabled and a disk is in place; otherwise, writing to this line will have no effect. • TKO goes to 0 only if the head is at track 0. This is valid beginning 12 msec after the step that puts it at track 0. •Writing 1 to EJECT ejects the disk from the drive. To eject a disk, you must hold LSTRB high for at least 1/2 second. • The current disk speed is available as a pulse train on T ACH. The TACH line produces 60 pulses for each rotation of the drive motor. The disk motor speed is controlled by the ASG as it reads the disk speed RAM buffer. • RDDATAO and RD DATA 1 carry the instantaneous data from the disk head. • SIDES is always 0 on single-sided drives and 1 on double-sided drives. • DRVIN is always 0 if the selected disk drive is physically connected to the Macintosh, otherwise it floats to 1. THE REAL-TIME CLOCK The Macintosh real-time clock is a custom chip whose interface lines are available through the VIA. The clock contains a four-byte counter that's incremented once each second, as well as a line that can be used by the VIA to generate an interrupt once each second. It also contains 20 bytes of RAM that are powered by a battery when the Macintosh is turned off. These RAM bytes, called parameter RAM, contain important data that needs to be preserved even when the system power is not available. The Operating System maintains a copy of parameter RAM that you can access in low memory. To find out how to use the values in parameter RAM, see chapter 13 of Volume Il. 111-36 The Disk Interface The Macintosh Hardware Accessing the Clock Chip The clock is accessed through the following bits of VIA data register B (vBase+vBufB): rTCData .EQU 0 ;real-time clock serial data line rTCClk .EQU 1 ;real-ti.me clock data-clock line rTCEnb .EQU 2 ;real-time clock serial enable These three bits constitute a simple serial interface. The rTCData bit is a bidirectional serial data line used to send command and data bytes back and forth. The rTCClk bit is a data-clock line, always driven by the processor (you set it high or low yourself) that regulates the transmission of the data and command bits. The rTCEnb bit is the serial enable line, which signals the real-time clock that the processor is about to send it serial commands and data. To access the clock chip, you must first enable its serial function. To do this, set the serial enable line (rTCEnb) to 0. Keep the serial enable line ~ow during the entire transaction; if you set it to 1, you'll abort the transfer. Warning: Be sure you don't alter any of bits 3-7 of VIA data register B during clock serial access. A command can be either a write request or a read request. After the eight bits of a write request, the clock will expect the next eight bits across the serial data line to be your data for storage into one of the internal registers of the clock. After receiving the eight bits of a read request, the clock will respond by putting eight bits of its data on the serial data line. Commands and data are transferred serially in eight-bit groups over the serial data line, with the high-order bit first and the low-order bit last. To send a command to the clock, first set the rTCData bit of VIA data direction register B (vBase+vDirB) so that the real-time clock's serial data line will be used for output to the clock. Next, set the rTCClk bit of vBase+vBufB to 0, then set the rTCData bit to the value of the first (high-order) bit of your data byte. Then raise (set to 1) the data-clock bit (rTCClk). Then lower the data-clock, set the serial data line to the next bit, and raise the data-clock line again. After the last bit of your command has been sent in this way, you can either continue by sending your data byte in the same way (if your command was a write request) or switch to receiving a data byte from the clock (if your command was a read request). To receive a byte of data from the clock, you must first send a command that's a read request. After you've clocked out the last bit of the command, clear the rTCData bit of the data direction register so that the real-time clock's serial data line can be used for input from the clock; then lower the data-clock bit (rTCClk) and read the first (high-order) bit of the clock's data byte on the serial data line. Then raise the data-clock, lower it again, and read the next bit of data. Continue this until all eight bits are read, then raise the serial enable line (rTCEnb }, disabling the data transfer. The following table lists the commands you can send to the clock. A 1 in the high-order bit makes your command a read request; a 0 in the high-order bit makes your command a write request. (In this table, "z" is the bit that determines read or write status, and bits marked "a" are bits whose values depend on what parameter RAM byte you want to address.) The Real-Time Clock lll-37 Inside Macintosh Command byte Register addressed by the command zOOOOOOl Seconds register 0 (lowest-order byte) z0000101 Seconds register 1 z0001001 Seconds register 2 zOOOl 101 Seconds register 3 (highest-order byte) 00110001 Test register (write only) 00110101 Write-protect register (write only) z010aa01 RAM address 1OOaa ($10-$13) zlaaaaOl RAM address Oaaaa ($00-$0F) Note that the last two bits of a command byte must always be 01. If the high-order bit (bit 7) of the write-protect register is set, this prevents writing into any other register on the clock chip (including parameter RAM). Clearing the bit allows you to change any values in any registers on the chip. Don't try to read from this register; it's a write-only register. The two highest-order bits (bits 7 and 6) of the test register are used as device control bits during testing, and should always be set to 0 during normal operation. Setting them to anything else will interfere with normal clock counting. Like the write-protect register, this is a write-only register; don't try to read from it. All clock data must be sent as full eight-bit bytes, even if only one or two bits are of interest. The rest of the bits may not matter, but you must send them to the clock or the write will be aborted when you raise the serial enable line. It's important to use the proper sequence if you're writing to the clock's seconds registers. If you write to a given seconds register, there's a chance that the clock may increment the data in the next higher-order register during the write, causing unpredictable results. To avoid this possibility, always write to the registers in low-to-high order. Similarly, the clock data may increment during a read of all four time bytes, which could cause invalid data to be read. To avoid this, always read the time twice (or until you get the same value twice). Warning: When you've finished reading from the clock registers, always end by doing a final write such as setting the write-protect bit. Failure to do this may leave the clock in a state that will run down the battery more quickly than necessary. The One-Second Interrupt The clock also generates a VIA interrupt once each second (if this interrupt is enabled). The enable status for this interrupt can be read from or written to bit 0 of the VlA's interrupt enable register (vBase+vIER). When reading the enable register, a 1 bit indicates the interrupt is enabled, and 0 means it's disabled. Writing $01 to the enable register disables the clock's one- second interrupt (without affecting any other interrupts), while writing $81 enables it again. See chapter 6 of Volume Il for more information about writing your own interrupt handlers. Warning: Be sure when you write to bit 0 of the VIA's interrupt enable register that you don't change any of the other bits. 111-38 The Real-Time Clock The Macintosh Hardware THE VIA The Synertek SY6522 Versatile Interface Adapter (VIA) controls the keyboard, internal real- time clock, parts of the disk, sound, and mouse interfaces, and various internal Macintosh signals. Its base address is available as the constant vBase and is also stored in a global variable named VIA. The VIA is on the upper byte of the data bus, so use even-addressed byte accesses only. There are two parallel data registers within the VIA, called A and B, each with a data direction register. There are also several event timers, a clocked shift register, and an interrupt flag register with an interrupt enable register. Normally you won't have to touch the direction registers, since the Operating System sets them up for you at system startup. A 1 bit in a data direction register means the corresponding bit of the respective data register will be used for output, while a 0 bit means it will be used for input. Note: For more information on the registers and control structure of the VIA, consult the technical specifications for the SY6522 chip. VIA Register A VIA data register A is at vBase+vBufA. The corresponding data direction register is at vBase+vDirA. Bit(s) Name Description 7 vSCCWReq sec wait/request 6 vPage2 Alternate screen buffer 5 vHeadSel Disk SEL line 4 vOverlay ROM low-memory overlay 3 vSndPg2 Alternate sound buffer 0-2 vSound (mask) Sound volume The vSCCWReq bit can signal that the SCC has received a character (used to maintain serial communications during disk accesses, when the CPU's interrupts from the SCC are disabled). The vPage2 bit controls which screen buffer is being displayed, and the vHeadSel bit is the SEL control line used by the disk interface. The vOverlay bit (used only during system startup) can be used to place another image of ROM at the bottom of memory, where RAM usually is (RAM moves to $600000). The sound buffer is selected by the vSndPg2 bit. Finally, the vSound bits control the sound volume. VIA Register B VIA data register Bis at vBase+vBufB. The corresponding data direction register is at vBase+vDirB. The VIA III-39 Inside Macintosh Bit Name Description 7 vSndEnb Sound enable/disable 6 vH4 Horizontal blanking 5 vY2 MouseY2 4 vX2 MouseX2 3 vSW Mouse switch 2 trCEnb Real-time clock serial enable 1 trCClk Real-time clock data-clock line 0 trCData Real-time clock serial data The vSndEnb bit turns the sound generator on or off, and the vH4 bit is set when the video beam is in its horizontal blanking period. The vY2 and vX2 bits read the quadrature signals from the Y (vertical) and X (horizontal) directions, respectively, of the mouse's motion lines. The vSW bit reads the mouse switch. The trCEnb, trCClk, and trCData bits control and read the real-time clock. The VIA Peripheral Control Register The VIA's peripheral control register, at vBase+vPCR, allows you to set some very low-level parameters (such as positive-edge or negative-edge triggering) dealing with the keyboard data and clock intenupts, the one-second real-time clock intenupt line, and the vertical blanking intenupt. Bit(s) Description 5-7 Keyboard data interrupt control 4 Keyboard clock interrupt control 1-3 One-second interrupt control 0 Vertical blanking interrupt control The VIA Timers The timers controlled by the VIA are called timer 1 and timer 2. Timer 1 is used to time various events having to do with the Macintosh sound generator. Timer 2 is used by the Disk Driver to time disk 1/0 events. If either timer isn't being used by the Operating System, you're free to use it for your own purposes. When a timer counts down to 0, an intenupt will be generated if the proper intenupt enable has been set. See chapter 6 of Volume II for information about writing your own interrupt handlers. To start one of the timers, store the appropriate values in the high- and low-order bytes of the timer counter (or the timer 1 latches, for multiple use of the value). The counters and latches are at the following locations: III-40 The VIA The Macintosh Hardware Location Contents vBase+vTlC Timer 1 counter (low-order byte) vBase+vTlCH Timer 1 counter (high-order byte) vBase+vTlL Timer 1 latch (low-order byte) vBase+vTlLH Timer 1 latch (high-order byte) vBase+vT2C Timer 2 counter (low-order byte) vBase+vT2CH Timer 2 counter (high-order byte) Note: When setting a timer, it's not enough to simply store a full word to the high-order address, because the high- and low-order bytes of the counters are not adjacent. You must explicitly do two stores, one for the high-order byte and one for the low-order byte. VIA Interrupts The VIA (through its IRQ line) can cause a level-0 processor interrupt whenever one of the following occurs: Timer 1 or timer 2 times out; the keyboard is clocking a bit in through its serial port; the shift register for the keyboard serial interface has finished shifting in or out; the vertical blanking interval is beginning; or the one-second clock has ticked. For more information on how to use these interrupts, see chapter 6 of Volume II. The interrupt flag register at vBase+vIFR contains flag bits that are set whenever the interrupt corresponding to that bit has occurred. The Operating System uses these flags to determine which device has caused an interrupt Bit 7 of the interrupt flag register is not really a flag: It remains set (and the IRQ line to the processor is held low) as long as any enabled VIA interrupt is occurring. Bit Interrupting device 7 IRQ (all enabled VIA interrupts) 6 Timer 1 5 Timer2 4 Keyboard clock 3 Keyboard data bit 2 Keyboard data ready 1 Vertical blanking interrupt 0 One-second interrupt The interrupt enable register, at vBase+vIER, lets you enable or disable any of these interrupts. If an interrupt is disabled, its bit in the interrupt flag register will continue to be set whenever that interrupt occurs, but it won't affect the IRQ flag, nor will it interrupt the processor. The bits in the interrupt enable register are arranged just like those in the interrupt flag register, except for bit 7. When you write to the interrupt enable register, bit 7 is "enable/disable": If bit 7 is a 1, each 1 in bits 0-6 enables the corresponding interrupt; if bit 7 is a 0, each 1 in bits 0-6 disables that interrupt In either case, O's in bits 0-6 do not change the status of those interrupts. Bit 7 is always read as a 1. The VIA /II-41 Inside Macintosh Other VIA Registers The shift register, at vBase+vSR, contains the eight bits of data that have been shifted in or that will be shifted out over the keyboard data line. The auxiliary control register, at vBase+vACR, is described in the SY6522 documentation. It controls various parameters having to do with the timers and the shift register. SYSTEM STARTUP When power is first supplied to the Macintosh, a carefully orchestrated sequence of events takes place. First, the processor is held in a wait state while a series of circuits gets the system ready for operation. The VIA and IWM are initialized, and the mapping of ROM and RAM are altered temporarily by setting the overlay bit in VIA data register A. This places the ROM starting at the normal ROM location $400000, and a duplicate image of the same ROM starting at address 0 (where RAM normally is), while RAM is placed starting at $600000. Under this mapping, the Macintosh software executes out of the normal ROM locations above $400000, but the MC68000 can obtain some critical low-memory vectors from the ROM image it finds at address 0. Next, a memory test and several other system tests take place. After the system is fully tested and initialized, the software clears the VIA's overlay bit, mapping the system RAM back where it belongs, starting at address 0. Then the disk startup process begins. First the internal disk is checked: If there's a disk inserted, the system attempts to read it. If no disk is in the internal drive and there's an external drive with an inserted disk, the system will try to read that one. Otherwise, the question-mark disk icon is displayed until a disk is inserted. If the disk startup fails for some reason, the "sad Macintosh" icon is displayed and the Macintosh goes into an endless loop until it's turned off again. Once a readable disk has been inserted, the first two sectors (containing the system starrup blocks) are read in and the normal disk load begins. III-42 The VIA The Macintosh Hardware SU M MARY Warning: This information applies only to the Macintosh 128K and 512K, not to the Macintosh XL. Constants ; VIA base addresses vBase .EQU $EFE1FE ;main base for VIA chip (in variable VIA) aVBufB .EQU vBase ;register B base aVBufA .EQU $EFFFFE ;register A base aVBufM .EQU aVBufB ;register containing mouse signals aVIFR .EQU $EFFBFE ;interrupt flag register a VIER .EQU $EFFDFE ;interrupt enabl e register ; Offsets from vBase vBufB .EQU 512*0 ;register B (zero offset) vDirB .EQU 512*2 ;register B direction register vDirA .EQU 512*3 ;register A direction register vTlC . EQU 512*4 ;timer 1 counter (low- order byte) vTlCH .EQU 512*5 ;timer 1 counter (high- order byte) vTlL .EQU 512*6 ;timer 1 lat ch (low- order byte) vTlLH .EQU 512*7 ;timer 1 latch (high- order byte) vT2C .EQU 512*8 ; timer 2 counter (l ow-order byte) vT2CH .EQU 512*9 ;timer 2 counter (high-order byte) vSR .EQU 512*10 ;shift register (keyboard) vACR .EQU 512*11 ;auxiliary control register vPCR .EQU 512*12 ;peripheral control register vIFR . EQU 512*13 ;interrupt flag register vIER .EQU 512*14 ;interrupt enable register vBufA .EQU 512*15 ; r egi ster A ; VIA register A constants vAOut .EQU $7F ;direction register A: 1 bits = outputs vAinit . EQU $7B ;initial value for vBufA (medium volume) vSound . EQU 7 ;sound volume bits ; VIA register A bit numbers vSndPg2 .EQU 3 ;O = alternate sound buffer vOverlay .EQU 4 ;l = ROM overlay (system startup only) vHeadSel .EQU 5 ;disk SEL control line vPage2 .EQU 6 ;O = alternate screen buffer vSCCWReq .EQU 7 ;SCC wait/request line Summary 11/43 Inside Macintosh ; VIA register B ::onstants vBOut .EQU $87 ;direction register B: 1 bits outputs vBinit .EQU $07 ;initial value for vBufB ; VIA register B bit numbers rTCData .EQU 0 ;real- time clock ser ial data line rTCClk .EQU 1 ;real- time clock data- clock l ine rTCEnb .EQU 2 ;real- time clock serial enable vsw .EQU 3 ;0 = mouse button is down vX2 .EQU 4 ;mouse X quadrature level vY2 .EQU 5 ;mouse Y quadrature level vH4 .EQU 6 ;l horizontal blanking vSndEnb . EQU 7 ;0 = sound enabled, 1 = disabled ; sec base addresses sccRBase .EQU $9FFFF8 ;SCC base read address (in variable SCCRd) sccWBase .EQU $BFFFF9 ;SCC base write address (in variable SCCWr) ; Offsets from SCC base addresses aData .EQU 6 ;channel A data in or out aCtl . EQU 2 ;channel A control bData .EQU 4 ;channel B data in or out bCtl .EQU 0 ;channel B control ; Bit numbers for control register RRO rxBF .EQU 0 ;1 sec receive buffer full txBE .EQU 2 ;1 sec send buffer empty ; IWM base address dBase .EQU $DFE1FF ;IWM base address (in variable IWM) ; Offsets from dBase phOL .EQU 512*0 ;CAO off (0) phOH .EQU 512*1 ;CAO on (1) phlL .EQU 512*2 ;CAl off (0) phl H .EQU 512*3 ;CAl on (1) ph2L .EQU 512*4 ;CA2 off (0) ph2H .EQU 512*5 ;CA2 on (1) ph3L .EQU 512*6 ;LSTRB off (low) ph3H .EQU 512*7 ;LSTRB on (high) mtrOff .EQU 512*8 ;disk enabl e off mtrOn .EQU 512*9 ;disk enable on intDrive .EQU 512*10 ;select internal drive extorive .EQU 512*11 ;select external drive q6L .EQU 512*12 ;Q6 off III-44 Summary The Macintosh Hardware q6H . EQU 512*13 ;Q6 on q7L .EQU 512*14 ;Q7 off q7H .EQU 512*15 ;Q7 on Screen and sound addresses for 512K Macintosh (will also work for 128K, since addresses wrap) screenLow . EQU $7A700 ;top left corner of main screen buffer soundLow .EQU $7FDOO ;main sound buffer (in variable SoundBase) pwmBuffer . EQU $7FD01 ;main disk speed buffer ovlyRAM .EQU $600000 ;RAM start address when overlay is set ovlyScreen .EQU $67A700 ;screen start with overlay set romStart . EQU $400000 ;ROM start address (in variable ROMBase ) Variables ROMBase Base address of ROM SoundBase Address of main sound buffer SCCRd sec read base address SCCWr sec write base address IWM IWM base address VIA VIA base address Exception Vectors Location Purpose $00 Reset: initial stack pointer (not a vector) $04 Reset: initial vector $08 Bus error $0C Address error $10 Illegal instruction $14 Divide by zero $18 CHK instruction $1C TRAPV instruction $20 Privilege violation $24 Trace interrupt $28 Line 1010 emulator $2C Line 1111 emulator $30-$3B Unassigned (reserved) $3C Uninitialized interrupt $40-$5F Unassigned (reserved) Swnmary III-45 Inside Macintosh Location Purpose $60 Spurious interrupt $64 VIA interrupt $68 sec interrupt $6C VIA+SCC vector (temporary) $70 Interrupt switch $74 Interrupt switch + VIA $q8 Interrupt switch + SCC $7C Interrupt switch + VIA + SCC $80-$BF TRAP instructions $CO-$FF Unassigned (reserved) 1//-46 Summary 3 SUMMARY 49 About This Chapter 50 AppleTalk Manager 65 Binary-Decimal Conversion Package 66 Control Manager 71 Desk Manager 73 Device Manager 80 Dialog Manager 85 Disk Driver 88 Disk Initialization Package 90 Event Manager, Operating System 94 Event Manager, Toolbox 98 File Manager 113 Font Manager 118 International Utilities Package 124 Memory Manager 130 Menu Manager 134 Package Manager 135 Printing Manager 141 QuickDraw 154 Resource Manager 157 Scrap Manager 159 Segment Loader 161 Serial Drivers 165 Sound Driver 172 Standard File Package 176 System Error Handler 179 TextEdit 184 Utilities, Operating System 190 Utilities, Toolbox 193 Vertical Retrace Manager 195 Window Manager 201 Assembly Language 201 Miscellaneous Variables 201 Hardware Contents JJJ-47 Inside Macintosh III-48 Summary ABOUT THIS CHAPTER This chapter includes all the summaries that appear at the end of other chapters of Inside Macintosh. The summaries are arranged in alphabetical order of the pan of the Toolbox or Operating System being summarized. Note: The summaries of the Event Managers are listed under "Event Manager, Operating System" and "Event Manager, Toolbox". The Toolbox and Operating System Utilities are listed similarly. The last section of this chapter, "Assembly Language" , contains information for assembly- language programmers only. It lists some miscellaneous global variables along with hardware- related definitions for the Macintosh 128K and 512K. About This Chapter III-49 Inside Macintosh APPLETALK MANAGER Constants CONST lapSize 20; {ABusRecord size for ALAP} ddpSize 26; {ABusRecord size for DDP} nbpSize 26; {ABusRecord size for NBP} atpSize 56; {ABusRecord size for ATP} Data Types TYPE ABProtoType (lapProto,ddpProto,nbpProto,atpProto); ABRecHandle "ABRecPtr; ABRecPtr "ABusRecord; ABusRecord RECORD abOpcode: ABCallType; {type of call} abResult: INTEGER; {result code } abUserReference: LONGINT; {for your use} CASE ABProtoType OF lapProto: (lapAddress: LAPAdrBlock; {destination or source node ID} lapReqCount: INTEGER; {length of frame data or buffer { size in bytes } lapActCount INTEGER; {number of frame dat a bytes } { actually received} lapDataPtr : Ptr); {pointer to frame data o r pointer { to buffer} ddpProto : (ddpType: Byte; {DDP protocol type } ddpSocket: Byte; {source or listening socket number} ddpAddress: AddrBlock; {destination or source socket address } ddpReqCount: INTEGER; {length of datagram data or buffer } { size in bytes} ddpActCount: INTEGER; {number of bytes actually received} ddpDataPtr : Ptr; {pointer to buffer} ddpNodeID: Byte) ; {original destination node ID} nbpProto: (nbpEntityPtr: EntityPtr; {poi nter to entity name } nbpBufPtr: Ptr; {pointer to buffer} nbpBufSize : INTEGER; {buf fe r size i n bytes } nbpDataField: INTEGER; {number of addresses or { socket number} nbpAddress : AddrBlock; {socket address} nbpRetransmitinfo: RetransType); {retransmission informat ion } III-50 AppleTalk Manager Summary atpProto: (atpSocket: Byte; {listening or responding socket { number} atpAddress: AddrBlock; {destination or source socket { address} atpReqCount: INTEGER; {request size or buffer size} atpDataPtr Ptr; {pointer to buffer} atpRspBDSPtr: BDSPtr; {pointer to response BDS) atpBitMap: BitMapType; {transaction bit map} atpTransID : INTEGER; {transaction ID) atpActCount: INTEGER; {number of bytes actually received} atpUserData : LONGINT; {user bytes } atpXO: BOOLEAN; {exactly-once f lag } atpEOM: BOOLF-AN; {end-of-message flag} atpTimeOut: Byte; {retry timeout interval i n seconds} atpRetries: Byte; {maximum number of retries} atpNuroBufs : Byte; {number of elements in response { BDS or number of r esponse } { packets sent} atpNumRsp: Byte; {number of response packets { received or sequence number } atpBDSSize: Byte; {number of elements in response BDS} atpRspUData: LONGINT; {user bytes sent or received in } { transaction response) atpRspBuf: Ptr; {pointer to response message buffer} atpRspSize: INTEGER); {size of response message buffer} END; ABCallType (tLAPRead,tLAPWrite,tDDPRead,tDDPWrite , tNBPLookup, tNBPConfirm, tNBPRegister,tATPSndRequest, tATPGetRequest,tATPSdRsp , tATPAddRsp , t ATPRequest , tATPResponse); LAPAdrBlock PACKED RECORD dstNodeID: Byte; {destination node ID} srcNodeID: Byte; {source node ID } lapProtType: ABByte {ALAP protocol t ype } END; ABByte = 1 .. 127; {ALAP protocol type} AddrBlock = PACKED RECORD aNet: INTEGER; {network number} aNode : Byte; {node ID} aSocket : Byte {socket number } END; BDSPtr "BDSType; BDSType ARRAY[0 .. 7] OF BDSElement; {response BDS } AppleTalkManager JJJ-51 Inside Macintosh BDSElement RECORD buffSize: INTEGER; {buffer size in bytes} buffPtr: Ptr ; {pointer to buffer} dataSize: INTEGER; {number of bytes actually received} userBytes: LONGINT {user bytes} END; BitMapType PACKED ARRAY [0 . . 7 ] OF BOOLEAN; EntityPtr "EntityNarne; EntityName RECORD objStr: Str32; {object} typeStr: Str32; {type} zoneStr: Str32 {zone} END; Str32 = STRING[32]; RetransType = PACKED RECORD retransinterval: Byte; {retransmit interval in 8-tick units } retransCount : Byte {total number of attempts } END; Routines [Not in ROM] Opening and Closing AppleTalk FUNCTION MPPOpen : OSErr; FUNCTION MPPClose : OSErr; AppleTalk Link Access Protocol FUNCTION LAPOpenProtocol (theLAPType: ABByte; protoPtr: Ptr) : OSErr; FUNCTION LAPCloseProtocol (theLAPType: ABByte) : OSErr; FUNCTION LAPWrite (abRecord : ABRec Handle; async : BOOLEAN) : OSErr; f- abOpcode {always tLAPWrite} f- abResult {result code} ~ abUserReference {for your use} ~ lapAddress.dstNodeID {destination node ID} ~ lapAddress.lapProtType {ALAP protocol type} ~ lapReqCount {length of frame data} ~ lapDataPtr {pointer to frame data} III-52 AppleTalk Manager Summary FUNCTION LAPRead (abRecord: ABRecHandle; async: BOOLEAN) OSErr; f- abOpcode {always tLAPRead} f- abResult {result code} ---7 abUserReference {for your use} f- lapAddress.dstNodeID {destination node ID} f- IapAddress.srcNodeID {source node ID} ---7 lapAddress.lapProtType {ALAP protocol type} ---7 lapReqCount {buffer size in bytes} f- lapActCount {number of frame data bytes actually received} ---7 lapDataPtr {pointer to buffer} FUNCTION LAPRdCancel (abRecord: ABRecHandle) OSErr; Datagram Delivery Protocol FUNCTION DDPOpenSocket (VAR theSocket: Byte; sktListener: Ptr) : OSErr; FUNCTION DDPCloseSocket (theSocket: Byte) : OSErr; FUNCTION DDPWrite (abRecord: ABRecHandle; doChecksurn: BOOLEAN; async: BOOLEAN) : OSErr; f- abOpcode {always tDDPWrite} f- abResult {result code} ---7 abUserReference {for your use} ---7 ddpType {DDP protocol type} ---7 ddpSocket {source socket number} ---7 ddpAddress {destination socket address} ---7 ddpReqCount {length of datagram data} ---7 ddpDataPtr {pointer to buffer} FUNCTION DDPRead (abRecord: ABRecHandle; retCksumErrs: BOOLEAN; async: BOOLEAN) : OSErr; f- abOpcode {always tDDPRead} f- abResult {result code} ---7 abUserReference {for your use} f- ddpType {DDP protocol type} ---7 ddpSocket {listening socket number} f- ddpAddress {source socket address} ---7 ddpReqCount {buffer size in bytes} f- ddpActCount {number of bytes actually received} ---7 ddpDataPtr {pointer to buffer} f- ddpNodelD {original destination node ID} FUNCTION DDPRdCancel (abRecord: ABRecHandle) : OSErr; AppleTalk Tran saction Pro tocol FUNCTION ATPLoad : OSErr; FUNCTION ATPUnload OSErr; FUNCTION ATPOpenSocket (addrRcvd: AddrBlock; VAR atpSocket: Byte) OSErr; FUNCTION ATPCloseSocket (atpSocket: Byte) : OSErr; AppleTalk Manager JJ/-53 Inside Macintosh FUNCTION ATPSndRequest (abRecord: ABRecHandle; async: BOOLEAN) OSErr; f- abOpcode {always tA1PSndRequest} f- abResult {result code} -7 abUserReference {for your use} -7 atpAddress {destination socket address} -7 atpReqCount {request size in bytes} -7 atpDataPtr {pointer to buffer} -7 atpRspBDSPtr {pointer to response BDS} -7 atpUserData {user bytes} -7 atpXO {exactly-once flag} f- atpEOM {end-of-message flag} -7 atpTureOut {retry timeout interval in seconds} -7 atpRetries {maximum number of retries} -7 atpNumBufs {number of elements in response BDS} f- atpNumRsp {number of response packets actually received} FUNCTION ATPRequest (abRecord: ABRecHandle; async: BOOLEAN) : OSErr; f- abOpcode {always tA1PRequest} f- abResult {result code} -7 abUserReference {for your use} -7 atpAddress {destination socket address} -7 atpReqCount {request size in bytes} -7 atpDataPtr {pointer to buffer} f- atpActCount {number of bytes actually received} -7 atpUserData {user bytes} -7 atpXO {exactly-once flag} f- atpEOM {end-of-message flag} -7 atpTmteOut {retry timeout interval in seconds} -7 atpRetries {maximum number of retries} f- atpRspUData {user bytes received in transaction response} -7 atpRspBuf {pointer to response message buffer} -7 atpRspSize {size of response message buffer} FUNCTION ATPReqCancel (abRecord: ABRecHandle; a s ync: BOOLEAN) : OSErr; FUNCTION ATPGetRequest (abRecord: ABRecHandle ; async: BOOLEAN) : OSErr; f- abOpcode {always tATPGetRequest} f- abResult {result code} -7 abUserReference {for your use} -7 atpSocket {listening socket number} f- atpAddress {source socket address} -7 atpReqCount {buffer size in bytes} -7 atpDataPtr {pointer to buffer} f- atpBitMap {transaction bit map} f- atpTransID {transaction ID} f- atpActCount {number of bytes actually received} f- atpUserData {user bytes} f- atpXO {exactly-once flag} 111-54 App/eTa/k Manager Summa.ry FUNCTION ATPSnd.Rsp (abRecord: ABRecHandle; async: BOOLEAN) OSErr; t- abOpcode {always tA1PSdRsp} t- abResult {result code} ~ abUserReference {for your use} ~ atpSocket {responding socket number} ~ atpAddress {destination socket address} ~ alpRspBDSPtr {pointer to response BDS} ~ atpTransID {transaction ID} ~ atpEOM {end-of-message flag} ~ atpNumBufs {number of response packets being sent} ~ atpBDSSize {numberof elements in response BDS} FUNCTION ATPAddRsp (abRecord: ABRecHandle) : OSErr; t- abOpcode {always tA1PAddRsp} t- abResult {result code} ~ abUserReference {for your use} ~ atpSocket {responding socket number} ~ atpAddress {destination socket address} ~ atpReqCount {buffer size in bytes} ~ atpDataPtr {pointer to buffer} ~ atpTransID {transaction ID} ~ atpUserData {user bytes} ~ atpEOM {end-of-message flag} ~ atpNumRsp {sequence number} FUNCTION ATPResponse (abRecord: ABRecHandle; async: BOOLEAN) OSErr; t- abOpcode {always tA1PResponse} t- abResult {result code} ~ abUserReference {for your use} ~ a1pSocket {responding socket number} ~ atpAddress {destination socket address} ~ atpTransID {transaction ID) ~ atpRspUData {user bytes sent in transaction response} ~ atpRspBuf {pointer to response message buffer} ~ atpRspSize {size of response message buffer} FUNCTION ATPRspCancel (abRecord : ABRecHandle; async: BOOLEAN) OSErr; Name-Binding Protocol FUNCTION NBPRegister (abRecord : ABRecHandle; async: BOOLEAN) OSErr ; t- abOpcode {always tNBPRegister} t- abResult {result code} ~ abUserReference {for your use} ~ nbpEntityPtr {pointer to entity name} ~ nbpBufPtr {pointer to buffer} ~ nbpBufSize {buffer size in bytes} ~ nbpAddress.aSocket {socket address} ~ nbpRetransmitinfo {retransmission information} AppleTalk Manager JJI-55 Inside Macintosh FUNCTION NBPLookup (abRecord: ABRecHandle; async: BOOLEAN) OSErr; ~ abOpcode {always tNBPLook:up} ~ abResult {result code} ~ abUserReference {for your use} ~ nbpEntityPtr {pointer to entity name} ~ nbpButPtr {pointer to buffer} ~ nbpButSiz.e {buffer size in bytes} H nbpDataField {number of addresses received} ~ nbpRetransmitlnfo {retransmission infonnation} FUNCTION NBPExtract (theBuffer: Ptr; numinBuf: INTEGER; whichOne: INTEGER; VAR abEntity: EntityName; VAR address: AddrBlock) : OSErr; FUNCTION NBPConfirm (abRecord: ABRecHandle; async: BOOLEAN) : OSErr; ~ abOpcode {always tNBPConfirm} ~ abResult {result code} ~ abUserReference {for your use} ~ nbpEntityPtr {pointer to entity name} ~ nbpDataField {socketnumber} ~ nbpAddress {socket address} ~ nbpRetransmitlnfo {retransmission infonnation} FUNCTION NBPRemove (abEntity: EntityPtr) : OSErr; FUNCTION NBPLoad : OSErr; FUNCTION NBPUnload : OSErr; Miscellaneous Routines FUNCTION GetNodeAddress (VAR myNode,myNet: INTEGER) OSErr; FUNCTION IsMPPOpen BOOLEAN; FUNCTION IsATPOpen BOOLEAN; Result Codes Name Value Meaning atpBadRsp -3107 Bad response from ATPRequest atpLenErr -3106 ATP response message too large badATPSkt -1099 ATP bad responding socket badBuffNum -1100 ATP bad sequence number buf2Smal1Err -3101 ALAP frame too large for buffer DDP datagram too large for buffer cbNotFound - 1102 ATP control block not found cksumErr -3103 DDP bad checksum ddpLenErr -92 DDP datagram or ALAP data length too big 111-56 AppleTalk Manager Summary Name Value Meaning ddpSktErr -91 DDP socket error: socket already active; not a well-known socket; socket table full ; all dynamic socket numbers in use excessCollsns -95 ALAP no CTS received after 32 RTS's, or line sensed in use 32 times (not necessarily caused by collisions) extractErr -3104 NBP can't find tuple in buffer lapProtErr -94 ALAP error attaching/detaching ALAP protocol type: attach error when ALAP protocol type is negative, not in range, already in table, or when table is full; detach error when ALAP protocol type isn't in table nbpBuffOvr -1024 NBP buffer overflow nbpConfDiff -1026 NBP name confirmed for different socket nbpDuplicate -1027 NBP duplicate name already exists nbpNISErr - 1029 NBP names information socket error nbpNoConfirm -1025 NBP name not confirmed nbpNotFound -1028 NBP name not found noBridgeErr -93 No bridge found noDataArea -11 04 Too many outstanding ATP calls noErr 0 No error noMPPError - 3102 MPP driver not installed noRelErr - 1101 ATP no release received noSendResp - 1103 ATPAddRsp issued before ATPSndRsp portlnUse - 97 Driver Open error, port already in use portNotCf -98 Driver Open error, port not configured for this connection readQErr - 3105 Socket or protocol type invalid or not found in table recNotFnd -3108 ABRecord not found reqAborted - 1105 Request aborted reqFailed -1096 ATPSndRequest failed: retry count exceeded sktClosedErr -3109 Asynchronous call aborted because socket was closed before call was completed tooManyReqs - 1097 ATP too many concurrent requests tooManySkts - 1098 ATP too many responding sockets AppleTalk Manager 111-57 Inside Macintosh Assembly-Language Information Constants ; Serial port use types useFree .EQU 0 ;unconfigured useATalk .EQU 1 ;configured for AppleTalk useASync .EQU 2 ;configured for the Serial Driver ; Bit in PortBUse for .ATP driver status . atpLoadedBit . EQU 4 ;set i f .ATP driver is opened ; Unit numbers for AppleTalk drivers mppUnitNurn . EQU 9 ; .MPP driver atpUnitNurn .EQU 10 ; .ATP driver ; csCode values for Control calls (MPP) writeLAP .EQU 243 detachPH .EQU 244 attachPH .EQU 245 writeDDP .EQU 246 closes kt . EQU 247 openSkt .EQU 248 .1,oadNBP . EQU 249 confinnName .EQU 250 lookupName .EQU 251 rernoveName .EQU 252 registerName .EQU 253 killNBP .EQU 254 unloadNBP .EQU 255 ; csCode values for Control c alls (ATP) relRspCB .EQU 249 closeATPSkt .EQU 250 addResponse . EQU 251 sendResponse .EQU 252 getRequest .EQU 253 openATPSkt .EQU 254 sendRequest .EQU 255 relTCB . EQU 256 ; ALAP header lapDstAdr .EQU 0 ;destination node ID lapSrcAdr .EQU 1 ;source node ID lapType .EQU 2 ;ALAP protocol type 111-58 AppleTalk Manager Summary ; ALAP header size lapHdSz .EQU 3 ; ALAP protocol type values shortDDP .EQU 1 ;short DDP header longDDP .EQU 2 ;long DDP heade r i Long DDP header ddpHopCnt .EQU 0 ;count of bridges passed (4 bits) ddpLength .EQU 0 ;datagram length (10 bits) ddpChecksum .EQU 2 ;checksum ddpDstNet . EQU 4 ;destination network number ddpSrcNet .EQU 6 ;source network number ddpDstNode .EQU 8 ;destination node ID ddpSrcNode .EQU 9 ;source node ID ddpDstSkt .EQU 10 ;destination socket number ddpSrcSkt .EQU 11 ;source socket number ddpType .EQU 12 ;DDP protocol type ; DDP long header size ddpHSzLong . EQU ddpType+l i Short DDP header ddpLength .EQU 0 ;datagram length sDDPDstSkt .EQU ddpCheckstun ;destination socket number sDDPSrcSkt .EQU sDDPDstSkt+l ;source socket number sDDPType .EQU sDDPSrcSkt+l ;DDP protocol type ; DDP short header size ddpHSzShort .EQU sDDPType+l ; Mask for datagram length ddpLenMask .EQU $03FF ; Maximum size of DDP data ddpMaxData .EQU 586 ; ATP header atpControl . EQU 0 ;control information atpBitMap .EQU 1 ;bit map atpRespNo .EQU 1 ;sequence ntunber atpTransID .EQU 2 ;transaction ID atpUserData .EQU 4 ;user bytes AppleTalkManager JJl-59 Inside Macintosh ; ATP header size atpHdSz . EQU 8 ; DDP protocol type f or ATP packets atp .EQU 3 ; ATP function code atpReqCode .EQU $40 ;TReq packet atpRspCode . EQU $80 ;TResp packet atpRelCode .EQU $CO ;TRel packet ; ATPFlags control inforrnation bits sendChk .EQU 0 ;send-checksum bit tidValid .EQU 1 ;transaction ID validity bit atpSTSBit .EQU 3 ;send-transmission- stat us bit atpEOMBit . EQU 4 ;end-of-message bit atpXOBit . EQU 5 ;exactly-once bit ; Maximum number of ATP request packets atpMaxNum . EQU 8 ; ATP buffer data structure bdsBuffSz . EQU 0 ;size of data to send or buffer size bdsBuffAddr . EQU 2 ;pointer to data or buffer bdsDataSz .EQU 6 ;number of bytes actually received bdsUserData . EQU 8 ;user bytes ; BDS element size bdsEntrySz . EQU 12 ; NBP packet nbpControl .EQU 0 ;packet type nbpTCount . EQU 0 ;tuple count nbpID .EQU 1 ;packet identifier nbpTuple .EQU 2 ;start of first tuple ; DDP protocol type f or NBP packets nbp .EQU 2 Il/-60 App/eTa/k Manager Summary ; NBP packet types brRq .EQU 1 ;broadcast request lkUp .EQU 2 ;lookup request lkUpReply .EQU 3 ;lookup reply ; NBP tuple tupleNet . EQU 0 ;network number tupleNode .EQU 2 ;node ID tupleSkt .EQU 3 ;socket number tupleEnum . EQU 4 ;used internally tupleName .EQU 5 ;entity name ; Maximum number of tuples in NBP packet tupleMax . EQU 15 ; NBP meta-characters equals .EQU '=' ;"wild-card" meta-character star .EQU I* f ;"this zone" meta- character ; NBP names tabl e entry ntLink .EQU 0 ;pointer to next entry ntTuple . EQU 4 ;tuple ntSocket .EQU 7 ;socket number ntEntity .EQU 9 ;entity name ; NBP names information socket number nis . EQU 2 Routines Link Access Protocol WriteLAP function ~ 26 csCode word ;always writeLAP ~ 30 wdsPointer pointer ;write data structure AttachPH function ~ 26 csCode word ;always attachPH ~ 28 protType byte ;ALAP protocol type ~ 30 handler pointer ;protocol handler AppleTalk Manager III-61 Inside Macintosh DetachPH function ~ 26 csCode word ;always detachPH ~ 28 protType byte ;ALAP protocol type Datagram Delivery Protocol OpenSkt function ~ 26 csCode word ;always openSkt H 28 socket byte ;socket number ~ 30 listener pointer ;socket listener CloseSkt function ~ 26 csCode word ;always closeSkt ~ 28 socket byte ;socket number WriteDDP function ~ 26 csCode word ;always writeDDP ~ 28 socket byte ;socket number ~ 29 checksumFlag byte ;checksum flag ~ 30 wdsPointer pointer ;write data structure AppleTalk Transaction Protocol OpenATPSkt function ~ 26 csCode word ;always openATPSkt H 28 atpSocket byte ;socket number ~ 30 addrBlock long word ;socket request specification OoseATPSkt function ~ 26 csCode word ;always closeATPSkt ~ 28 atpSocket byte ;socket number SendRequest function ~ 18 userData long word ;user bytes f- 22 reqTID word ;transaction ID used in request ~ 26 csCode word ;always sendRequest f- 28 currBitMap byte ;bit map H 29 atpFlags byte ;control information ~ 30 addrBlock long word ;destination socket address ~ 34 reql.ength word ;request size in bytes ~ 36 reqPointer pointer ;pointer to request data ~ 40 bdsPointer pointer ;pointer to response BDS ~ 44 numOIBuffs byte ;number of responses expected ~ 45 timeOutVal byte ;timeout interval f- 46 numOfResps byte ;number of responses received H 47 retryCount byte ;number of retries GetRequest function f- 18 userData long word ;user bytes ~ 26 csCode word ;always getRequest ~ 28 atpSocket byte ;socket number III-62 AppleTalk Manager Swnmary GetRequest function ~ 18 userData long word ;user bytes ~ 26 csCode word ;always getRequest ~ 28 atpSocket byte ;socket number ~ 29 atpFlags byte ;control infonnation ~ 30 addrBlock long word ;source of request f-7 34 reqLength word ;request buffer size ~ 36 reqPointer pointer ;pointer to request buffer ~ 44 bitMap byte ;bitmap ~ 46 transID word ;transaction ID SendResponse function ~ 18 userData long word ;user bytes from 1Rel ~ 26 csCode word ;always sendResponse ~ 28 atpSocket byte ;socket number ~ 29 atpFlags byte ;control infonnation ~ 30 addrBlock long word ;response destination ~ 40 bdsPointer pointer ;pointer to response BDS ~ 44 numOfBuffs byte ;number of response packets being sent ~ 45 bdsSize byte ;BDS size in elements ~ 46 transID word ;transaction ID Add.Response function ~ 18 userData long word ;user bytes ~ 26 csCode word ;always addResponse ~ 28 atpSocket byte ;socket number ~ 29 atpFlags byte ;control infonnation ~ 30 addrBiock long word ;response destination ~ 34 reqLength word ;response size ~ 36 reqPointer pointer ;pointer to response ~ 44 rspNum byte ;sequence number ~ 46 transID word ;transaction ID RelTCB function ~ 26 csCode word ;always relTCB ~ 30 addrBlock long word ;destination of request ~ 46 transID word ;transaction ID of request RelRspCB function ~ 26 csCode word ;always relRspCB ~ 28 atpSocket byte ;socket number that request was received on ~ 30 addrBlock long word ;source of request ~ 46 transID word ;transaction ID of request AppleTalk Manager Ill-63 Inside Macintosh Name-Binding Protocol RegisterName function ~ 26 csCode word ;always registerName ~ 28 interval byte ;retry interval H 29 count byte ;retry count ~ 30 ntQEIPtr pointer ;names table element pointer ~ 34 verifyFlag byte ;set if verify needed LookupName function ~ 26 csCode word ;always lookupName ~ 28 interval byte ;retry interval H 29 count byte ;retry count ~ 30 entityPtr pointer ;pointer to entity name ~ 34 retBuffPtr pointer ;pointer to buffer ~ 38 retBuffSize word ;buffer size in bytes ~ 40 maxToGet word ;matches to get f- 42 numGotten word ;matches found ConfirmName function ~ 26 csCode word ;always confirmName ~ 28 interval byte ;retry interval H 29 count byte ;retry count ~ 30 entityPtr pointer ;pointer to entity name ~ 34 confirmAddr pointer ;entity address f- 38 newSocket byte ;socket number RemoveName function ~ 26 csCode word ;always removeName ~ 30 entityPtr pointer ;pointer to entity name LoadNBP function ~ 26 csCode word ;always loadNBP UnloadNBP function ~ 26 csCode word ;always unloadNBP Variables SPConfig Use types for serial ports (byte) (bits 0-3: current configuration of serial port B bits 4-6: current configuration of serial port A) PortBUse Current availability of serial port B (byte) (bit 7: 1 =not in use, 0 = in use bits 0-3: current use of port bits bits 4-6: driver-specific) ABusVars Pointer to AppleTalk variables 1//-64 AppleTalk Manager Summary BINARY-DECIMAL CONVERSION PACKAGE Routines PROCEDURE NumToString (theNum: LONGINT; VAR theString: Str255); PROCEDURE StringToNum (theString: Str255; VAR theNum: LONGINT); Assembly- Language Information Constants ; Routine selectors numToString .EQU 0 stringToNum .EQU 1 Routines Na me On entry On exit NumToString AO: ptr to theString (preceded by length byte) AO: ptr to theString DO: theNum (long) StringToNum AO: ptr to theString (preceded by length byte) DO: theNum (Jong) Trap Macro Name Pack? Binary-Decimal Conversion Package III-65 Inside Macintosh CONTROL MANAGER Constants CONST { Control definition IDs } pushButProc O; {simple button} checkBoxProc l; {check box} radioButProc 2; {radio button} useWFont 8; {add to above to use window's font } scrollBarProc 16; {scroll bar} { Part codes inButton 10; {simple button} inCheckBox 11; {check box or radio button} inUpButton 20; {up arrow of a scroll bar} inDownButton 21; {down arrow of a scroll bar} inPageUp 22; {"page up" region of a scroll bar} inPageDown 23; {"page down" region of a scroll bar} inThumb 12 9; {thumb of a scroll bar} { Axis constraints for DragControl noConstraint 0; {no constraint} hAxisOnly l; {horizontal axis only} vAxisOnly 2; {vertical axis only} { Messages to control definition function drawCntl O; {draw the control (or control part)} testCntl 1; {test where mouse button was pressed } calcCRgns 2; {calculate control's region (or indic ator's) } initCntl 3; {do any additional control initia lization } dispCntl 4; {take any additional disposal actions} posCntl 5; {reposition contr ol's indicator and update it} thumbCntl 6; {calculate parameters for dragging indicator} dragCntl 7; {drag control (or its indicator)} autoTrack 8; {execute control's action procedure} Data Types TYPE ControlHandle "ControlPtr; ControlPtr "ControlRecord; 111-66 Control Manager Summary ControlRecord = PACKED RECORD nextControl: ControlHandle; {next control} contrl Owner: Wi ndowPtr ; {control' s window} contrlRect: Rect; {enclosing rectangle} contrlVis: Byte; (255 i f visible} contrlHilite: Byte; {highlight state} contrlValue: INTEGER; {control ' s current setting} contrlMin: INTEGER; {control' s minimum setting} contrlMax : INTEGER; {control ' s maximum setting} contrlDefProc: Handle; {control definition function} contrlData: Handle; {data used by contrlDefProc} contrlAct ion: ProcPtr; {default action procedure} contrlRfCon : LONGINT; {control' s reference value} contrlTitle: St r 255 {control ' s t itle} END; Routines Initialization and Allocation FUNCTION NewControl (theWi ndow : WindowPtr ; boundsRect: Rect; title: St r 255; visible: BOOLEAN; value: I NTEGER; min , max: INTEGER; procID: INTEGER; refCon: LONGINT) : ControlHandle; FUNCTION GetNewControl (cont r o l ID: INTEGER; theWindow: WindowPtr) : ControlHandle; PROCEDURE DisposeControl (theContr o l : Cont rol Handle); PROCEDURE KillCont r ols (theWindow: WindowPtr); Control Display PROCEDURE SetCTitle (theControl: Cont r olHandle; title: Str255); PROCEDURE GetCTitle (theControl : ControlHandle; VAR title : Str255); PROCEDURE HideCont r ol (theControl: ControlHandle) ; PROCEDURE ShowControl (theControl : ControlHandle); PROCEDURE DrawCont r ols (theWindow : WindowPtr); PROCEDURE Hili teCont rol (theControl: ControlHandle; hiliteState: INTEGER); Mouse Location FUNCTION FindControl (thePoint : Point; theWindow : WindowPtr; VAR whichControl: ControlHandle) : INTEGER; FUNCTION TrackControl (theControl: ControlHandle; startPt: Point; actionP r oc: ProcPtr) : INTEGER; FUNCTION TestControl (theControl: ControlHandle; thePoint : Point) INTEGER; Control Manager l//-67 Inside Macintosh Control Movement and Sizing PROCEDURE MoveControl (theControl: ControlHandle; h,v: INTEGER); PROCEDURE DragControl (theControl: ControlHandle; startPt: Point; limitRect,slopRect: Rect; axis: INTEGER); PROCEDURE SizeControl (theControl: ControlHandle; w,h: INTEGER); Control Setting and Range PROCEDURE SetCtlValue (theControl: ControlHandle; theValue: INTEGER); FUNCTION GetCtlValue (theControl: ControlHandle) : INTEGER; PROCEDURE SetCtlMin (theControl: ControlHandle; minValue: INTEGER); FUNCTION GetCtlMin (theControl: ControlHandle) : INTEGER; PROCEDURE SetCtlMax (theControl: ControlHandle; maxValue INTEGER); FUNCTION GetCtlMax (theControl: ControlHandle) : INTEGER; Miscellaneous Ro utine s PROCEDURE SetCRefCon (theControl: ControlHandle; data: LONGINT); FUNCTION GetCRefCon (theControl: ControlHandle) : LONGINT; PROCEDURE SetCtlAction (theControl: ControlHandle; actionProc ProcPtr); FUNCTION GetCtlAction (theControl: ControlHandle) : ProcPtr; Action Procedure for TrackControl If an indicator: PROCEDURE MyAction; If not an indicator: PROCEDURE MyAction (theControl: ControlHandle; partCode: INTEGER); Control Definition Function FUNCTION MyControl (varCode: INTEGER; theControl: ControlHandle; message: INTEGER; param: LONGINT) : LONGINT; Assembly-Language Information Constants i Control definition IDs pushButProc .EQU 0 ; simple button checkBoxProc .EQU 1 ;check box radioButProc . EQU 2 ;radio button useWFont . EQU 8 ;add to above to use window's font scrollBarProc . EQU 16 ;scroll bar III-68 Control Manager Summary ; Part codes inButton .EQU 10 ;simple button inCheckBox .EQU 11 ;check box or radio button inUpButton .EQU 20 ;up arrow of a scr oll bar inDownButton .EQU 21 ;down arrow of a scroll bar inPageUp .EQU 22 ;"page up" region of a scroll bar inPageDown .EQU 23 ;"page down" region of a scroll bar inThumb .EQU 129 ;thumb of a scroll bar ; Axis constraints for DragControl noConstraint .EQU 0 ;no constraint hAxisOnly . EQU 1 ;horizontal axis only vAxisOnly . EQU 2 ;vertical axis only ; Messages to control definition function drawCtlMsg .EQU 0 ;draw the control (or control part) hitCtlMsg . EQU 1 ;test where mouse button was pressed calcCtlMsg .EQU 2 ;calculate control's region (or indicator's) newCtlMsg . EQU 3 ;do any additional control initialization dispCtlMsg . EQU 4 ;take any additional disposal actions posCtlMsg .EQU 5 ;reposition control's indicator and update it thurnbCtlMsg .EQU 6 ;calculate parameters for dragging indicator dragCtlMsg .EQU 7 ;drag control (or its indicator) trackCtlMsg .EQU 8 ;execute control's action procedure Control Record Data Structure nextControl Handle to next control in control list contrlOwner Pointer to this control's window contrlRect Control's enclosing rectangle (8 bytes) contrlVis 255 if control is visible (byte) contrlHilite Highlight state (byte) contrlValue Control's current setting (word) contrlMin Control's minimum setting (word) contrlMax Control's maximum setting (word) contrlDefHandle Handle to control definition function contrlData Data used by control definition function (long) contrlAction Address of default action procedure contrlRfCon Control's reference value (long) contrlTitle Handle to control's title {preceded by length byte) contrlSize Size in bytes of control record except contrlTitle field Control Manager 111-69 Inside Macintosh Special Macro Names Pascal name Macro name DisposeControl _ DisposControl GetCtlMax GetMaxCtl GetCtlMin -GetMinCtl SetCtlMax SetMaxCtl SetCtlMin SetMinCtl Variables DragHook Address of procedure to execute during TrackControl and DragControl DragPattem Pattern of dragged region's outline (8 bytes) /11-70 Control Manager Summary DESK MANAGER Routines Open ing and Clos ing Desk Accessories FUNCTION OpenDeskAcc (theAcc: Str255 ) : INTEGER; PROCEDURE CloseDeskAcc (refNum : INTEGER); Handling Events in Desk Accessorius PROCEDURE SystemClick (theEvent: EventR•:!cord; theWindow: WindowPtr) ; FUNCTION SystemEdit (editDnd: INTEGER) : BOOLEAN; Performing Periodic Actions PROCEDURE SystemTask; Advanced Routines FUNCTION SystemEvent (theEvent: EventR•:!Cord) BOOLEAN; PROCEDURE SystemMenu (rnenuResult: LONGINT); Assembly-Language Information Co nstants ; Desk accessory flag dNeedTime .EQU 5 ;set if driver needs time for performing a ; pe r iodi·: action ; Control routine messages accEvent .EQU 64 ;handle a given event accRun .EQU 65 ;take the periodic action , if any, for ; this desk accessory accCursor . EQU 66 ;change cursor shape if appropriate; ; generate null event if window was ; created by Dialog Manager accMenu .EQU 67 ;handle a given menu item a ccUndo .EQU 68 ;handle the Undo command Desk Manager 111-71 Inside Macintosh accCut .EQU 70 ;handle the Cut command accCopy .EQU 71 ;handle the Copy command accPaste .EQU 72 ;handle the Paste command accClear .EQU 73 ;handle the Clear command Special Macro Names Pascal name Macro name SystemEdit _SysEdit Variables MBarEnable Unique menu ID for active desk accessory, when menu bar belongs to the accessory (word) SEvtEnb 0 if SystemEvent should return FALSE (byte) Ill-72 Desk Manager Summary DEVICE MANAGER Constants CONST { Values for requesting read/write access } fsCurPerm 0; {whatever is currently allowed} fsRdPerm l; {request to read only} fsWrPerm 2; {request to write only} fsRd.WrPerm 3; {request to read and write} { Positioning modes fsAtMark 0; {at current position} fsFromStart l; {offset relative to beginning of medium} fsFrorrt1ark 3; {offset relative to current p os ition} rdVerify 64; {add to above for read-verify} Data Types TYPE ParamBlkType (ioParam,fileParam,volumeParam,cntrlParam); ParmBlkPtr = AParamBlockRec; ParamBlockRec RECORD qLink: QElemPtr; {next queue entry} qType: INTEGER; {queue type} ioTrap : INTEGER; {routine trap} ioCrndAddr: Ptr; {routine address} ioCompletion: ProcPtr; {completion routine} ioResult: OSErr; {result code} ioNamePtr: StringPtr; {driver name} ioVRefNum: INTEGER; {volume reference or drive number} CASE ParamBlkType OF ioParam: (ioRefNum: INTEGER; {driver reference number} ioVersNum: SignedByte; {not used} ioPermssn: SignedByte; {read/write permission} ioMisc: Ptr; {not used} ioBuffer: Ptr; {pointer to data buffer} ioReqCount: LONGINT; {requested number of bytes} ioActCount: LONGINT; {actual number of bytes} ioPosMode: INTEGER; {positioning mode} ioPosOffset: LONGINT); {positioning offset} fileParam: . . . {used by File Manager} volumeParam : . . . {used by File Manager} Device Manager /11-73 Inside Macintosh cntrlParam: (ioCRefNum: INTEGER; {driver reference number} csCode: INTEGER; {type of Control o r Status call} csParam: ARRAY[0 .. 10) OF INTEGER) {control or status information} END; DCtlHandle "OCtlPtr; DCtlPtr "DCtlEntry; DCtlEntry RECORD dCtlDriver : Ptr; {pointer t o ROM d river or handle t o l { RAM driver} dCtlFlags: INTEGER; {flags} dCtlQHdr : QHdr ; {driver I /O queue header) dCtlPosition: LONGINT; {byte position used by Read and { Write calls} dCtlStorage: Handle; {handle to RAM driver ' s private { storage} dCtlRefNum: INTEGER; {driver reference number } dCtlCurTicks : LONGINT; {used internally} dCtlWindow: WindowPtr; {pointer to driver ' s window} dCtlDelay: INTEGER; {number of ticks between periodic { actions} dCtlEMask: INTEGER; {desk accessory event mask } dCtlMenu: INTEGER {menu ID of menu associated with { driver} END; High-Level Routines (Not in ROM] FUNCTION OpenDriver (name: Str255; VAR refNum: INTEGER) : OSErr ; FUNCTION CloseDriver (refNum: INTEGER) : OSErr; FUNCTION FSRead (refNum: INTEGER; VAR count: LONGINT; buffPtr: Ptr) : OSErr ; FUNCTION FSWrite (refNum: INTEGER; VAR count : LONGINT; buffPtr: Ptr) : OSErr; FUNCTION Control (refNum: INTEGER; csCode: INTEGER; csParamPtr: Pt r ) : OSErr; FUNCTION Status (refNum: INTEGER; csCode : INTEGER; csParamPtr: Ptr) : OSErr; FUNCTION Kill IO (refNum : INTEGER) : OSErr ; Low-Level Routines FUNCTION PBOpen (paramBlock : ParmBlkPtr ; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer t-- 16 ioResult word ~ 18 ioNamePtr point.er t-- 24 ioRefNum word ~ Tl ioPermssn byte 111-74 Device Manager Summary FUNCTION PBClose (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer f-- 16 ioResult word ~ 24 ioRefNum word FUNCTION PBRead (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer f-- 16 ioResult word ~ 22 ioVRefNum word ~ 24 ioRefNum word ~ 32 ioBuffer pointer ~ 36 ioReqCount long word f-- 40 ioActCount long word ~ 44 ioPosMode word H 46 ioPosOffset long word FUNCTION PBWrite (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer f-- 16 ioResult word ~ 22 ioVRefNum word ~ 24 ioRefNum word ~ 32 ioBuffer pointer ~ 36 ioReqCount long word f-- 40 ioActCount long word ~ 44 ioPosMode word H 46 ioPosOffset long word FUNCTION PBControl (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer f-- 16 ioResult word ~ 22 ioVRefNum word ~ 24 ioRefNum word ~ 26 csCode word ~ 28 csParam record FUNCTION PBStatus (paramBlock : ParmBlkPtr; async : BOOLEAN) OSErr; ~ 12 ioCompletion pointer f-- 16 ioResult word ~ 22 ioVRefNum word ~ 24 ioRefNum word ~ 26 csCode word f-- 28 csParam record FUNCTION PBKillIO (paramBlock : ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer f-- 16 ioResult word ~ 24 ioRefNum word Device Manager ll!-75 Inside Macintosh Accessing a Driver's Device Control Entry FUNCTION GetDCtlEntry (refNum: INTEGER) : DCtlHandle; [NotinROM] Result Codes Name Value Meaning abortErr -27 1/0 request aborted by KillIO badUnitErr -21 Driver reference number doesn't match unit table controlErr -17 Driver can't respond to this Control call dlnstErr -26 Couldn't find driver in resource file dRemovErr -25 Attempt to remove an open driver no Err 0 No error notOpenErr -28 Driver isn't open openErr -23 Requested read/write permission doesn't match driver's open permission readErr -19 Driver can't respond to Read calls statusErr -18 Driver can't respond to this Status call unitEmpty Err -22 Driver reference number specifies NIL handle in unit table writErr -20 Driver can't respond to Write calls Assembly-Language Information Constants ; Flags in trap words asnycTrpBit .EQU 10 ;set for an asynchronous call noQueueBit .EQU 9 ;set for irmnediate execution ; Values for requesting read/write access fsCurPerm .EQU 0 ;whatever is currently allowed fsRdPerm .EQU 1 ;request to read only fsWrPerm .EQU 2 ;request to write only fsRdWrPerm .EQU 3 ;request to read and write ; Positioning modes fsAtMark .EQU 0 ;at current position fsFromStart .EQU 1 ;offset relative to beginning of medium fsFromMark . EQU 3 ;offset relative to current position rdVerify .EQU 64 ;add to above for read-verify III-76 Device Manager Summary ; Driver flags dReadEnable .EQU 0 ;set if driver can respond to Read calls dWritEnable .EQU 1 ;set if driver can respond to Write calls dCtlEnable . EQU 2 ;set if driver can respond to Control calls d.StatEnable . EQU 3 ;set if driver can respond to Status calls dNeedGood.Bye .EQU 4 ;set if driver needs to be called before the ; application heap is reinitialized dNeedTi.me .EQU 5 ;set if driver needs time for performing a ; periodic action dNeedLock .EQU 6 ;set if driver will be locked in memory as soon as it's opened (always set for ROM drivers) ; Device control entry flags dOpened .EQU 5 ;set i f driver is open d.RAMBased .EQU 6 ;set i f driver is RAM-based drvrActive .EQU 7 ; set i f driver is currently executing ; csCode values for driver control routine accRun . EQU 65 ;take the periodic action, if any, for this ; driver good.Bye . EQU -1 ;heap will be reinitialized, clean up if ; necessary killCode . EQU 1 ;handle the KillIO call ; Low-order byte of Device Manager traps aRdCmd .EQU 2 ;Read call (trap $A002) aWrCmd .EQU 3 ;Write cal l (trap $A003) ; Offsets from SCC base addresses aData .EQU 6 ;channel A data in or out aCtl .EQU 2 ;channel A control bData .EQU 4 ;channel B data in or out bCtl .EQU 0 ;channel B control Standard Parameter Block Data Structure qLink Pointer to next queue entry qType Queue type (word) ioTrap Routine trap (word) ioCmdAddr Routine address ioCompletion Address of completion routine ioResult Result code (word) ioVNPtr Pointer to driver name (preceded by length hyte) ioVRefNum Volume reference number (word) ioDrvNum Drive number (word) Device Manager Ill-77 Inside Macintosh Control and Status Parameter Block Data Structure ioRefNum Driver reference number (word) csCode Type of Control or Status call (word) csParam Parameters for Control or Status call (22 bytes) 1/0 Parameter Block Data Structure ioRefNum Driver reference number (word) ioPermssn Open permission (byte) ioBuffer Pointer to data buffer ioReqCount Requested number of bytes (long) ioActCount Actual number of bytes (long) ioPosMode Positioning mode (word) ioPosOffset Positioning offset (long) Device Driver Data Structure drvrFlags Flags (word) drvrDelay Number of ticks between periodic actions (word) drvrEMask Desk accessory event mask (word) drvrMenu Menu ID of menu associated with driver (word) drvrOpen Offset to open routine (word) drvrPrime Offset to prime routine (word) drvrCtl Offset to control routine (word) drvrStatus Offset to status routine (word) drvrClose Offset to close routine (word) drvrName Driver name (preceded by length byte) Device Control Entry Data Structure dCtlDriver Pointer to ROM driver or handle to RAM driver dCtlFlags Flags (word) dCtlQueue Queue flags: low-order byte is driver's version number (word) dCtlQHead Pointer to first entry in driver's 110 queue dCtlQTail Pointer to last entry in driver's 1/0 queue dCtlPosition Byte position used by Read and Write calls (long) dCtlStorage Handle to RAM driver's private storage dCtlRefNum Driver's reference number (word) dCtlWindow Pointer to driver's window dCtlDelay Number of ticks between periodic actions (word) dCtlEMask Desk accessory event mask (word) dCtlMenu Menu ID of menu associated with driver (word) Structure of Primary Interrupt Vector Table autoIntl Vector to level- I interrupt handler autolnt2 Vector to level-2 interrupt handler ///-78 Device Manager Summary autolnt3 Vector to level-3 interrupt handler autolnt4 Vector to level-4 interrupt handler autolnt5 Vector to level-5 interrupt hand~( autolnt6 Vector to level-6 interrupt handler autolnt7 Vector to level-7 interrupt handler Macro Names Pascal name Macro name PB Read Read PB Write Write PB Control Control PB Status Status PBKilllO KillIO Routines for Writing Drivers Routine Jump vector On entry On exit Fetch JPetch Al: ptr to device DO: character fetched; bit 15=1 control entry if last character in buffer Stash JStash Al : ptr to device DO: bit 15= 1 if last character control entry requested DO: character to stash IODone JIODone Al : ptr to device control entry DO: result code (word) Variables UTableBase Base address of unit table JFetch Jump vector for Fetch function JStash Jump vector for Stash function TIODone Jump vector for IODone function LvllDT Level-1 secondary interrupt vector table (32 bytes) Lvl2DT Level-2 secondary interrupt vector table (32 bytes) VIA VIA base address ExtStsDT External/status interrupt vector table (16 bytes) SCCWr sec write base address SCCRd sec read base address Device Manager Ill-79 Inside Macintosh DIALOG MANAGER Constants CONST { Item types ctrl item 4; {add to following four constants} btnCtrl O; {standard but ton control} chkCtrl l; {standard check box control} r adCtrl 2; {standard r adio button control} resCtrl 3; {control defined in control t emplat e} stat Text 8; {static text} editText 16; {editab l e text (dialog only) } i con Item 32; {icon} pici tem 64 ; {Qui ckDraw picture} use r Item 0; {appli c ation- defined item (dialog only)} itemDi sabl e 128; {add to any of above to disable } { I tem numbers of OK and Cancel buttons } ok 1; cancel 2; { Re source IDs of alert icons stopicon 0; note I con 1; cautionicon 2; Data Types TYPE Di a l ogPtr Wi ndowPt. r ; Di a l ogPeek "Dial ogRecord; Di a l ogRecord RECORD window : WindowReco r d; {dialog wi ndow} items : Handle; {item list} textH : TEHandl e; {current editText item } \ editFiel d: I NTEGER; {editText i tem number minus 1 ) \ edi tOpen: I NTEGER; {used internally} ' aDefitem : INTEGER {default button item number } \ END; Di alogTHndl "DialogTPtr; DialogTPtr "Dial ogTempl at e; III-80 Dialog Manager Summary DialogTernplate RECORD boundsRect: Rect ; {becomes window ' s port Rect} procID: INTEGER; {window definition ID} visible: BOOLEAN; {TRUE if visible} fillerl: BOOLEAN; {not used} goAwayFlag: BOOLEAN; {TRUE if has go-away region} filler2: BOOLEAN; {not used} refCon: LONGINT; {window's reference value} itemsID : INTEGER; {resource ID of item list} title: Str255 {window's title } END; AlertTHndl "AlertTPtr; AlertTPtr "Alert Template; Alert Template RECORD boundsRect: Rect; {becomes wi ndow's portRect} iternsID: INTEGER; {resource ID of item l ist} stages: StageList {alert stage i nformat ion} END: StageList PACKED RECORD bolditm4 : 0 •. 1; {default button item number minus 1 ) boxDrwn4: BOOLEAN; {TRUE if alert box to be drawn } sound4 : 0 .. 3 {sound number} bolditm3: O•• 1; boxDrwn3: BOOLEAN; sound3: 0 .. 3 bolditm2: 0 .. 1; boxDrwn2 : BOOLEAN; sound2: 0 .. 3 bolditml: 0 . . 1; boxDrwnl: BOOLEAN; soundl : O•• 3 END; Routines Initialization PROCEDURE InitDialogs (resumeProc: ProcPtr); PROCEDURE ErrorSound (soundProc: ProcPtr); PROCEDURE SetDAFont (fontNum: INTEGER); [NotinROM] Creating and Disposing of Dialogs FUNCTION NewDialog (dStorage: Ptr; boundsRect: Rect; title: Str255; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr ; goAwayFlag: BOOLEAN; refCon: LONGINT; items: Handle) : DialogPtr; Dialog Manager III-81 Inside Macintosh FUNCTION GetNewDialog (dialogID: INTEGER; dS torage : Ptr; behind : WindowPtr) : DialogPtr; PROCEDURE CloseDialog (theDialog : DialogPtr); PROCEDURE DisposDialog (theDialog: DialogPtr); PROCEDURE CouldDialog (dialogID: INTEGER); PROCEDURE FreeDialog (dialogID: INTEGER); Handling Dialog Events PROCEDURE ModalDialog (filterProc: ProcPtr; VAR i temHit: INTEGER); FUNCTION IsDialogEvent (theEvent: EventRecord) : BOOLEAN; FUNCTION DialogSelect (theEvent: EventRecord; VAR theDialog: DialogPtr; VAR itemHit: INTEGER) : BOOLEAN; PROCEDURE DlgCut (theDialog: DialogPtr) ; [Not in ROM] PROCEDURE DlgCopy (theDialog: DialogPtr); [Not in ROM] PROCEDURE DlgPaste (theDialog: DialogPtr); [Not in ROM] PROCEDURE DlgDelete (theDialog: DialogPtr); [Not in ROM] PROCEDURE DrawDialog (theDialog: DialogPtr); Invoking Alerts FUNCTION Alert (alertID: INTEGER; filterProc : ProcPtr) INTEGER; FUNCTION StopAlert (alertID: INTEGER; filterProc : ProcPtr) INTEGER; FUNCTION NoteAlert (alertID: INTEGER; filterProc : ProcPtr) INTEGER; FUNCTION CautionAlert (alertID: INTEGER; filterProc : ProcPtr) INTEGER; PROCEDURE CouldAlert (alertID: INTEGER); PROCEDURE FreeAlert (alertID: INTEGER); Manipulating Items in Dialogs and Alerts PROCEDURE ParamText (param0,paraml , param2,pararn3 : Str255); PROCEDURE GetDitem (theDialog: DialogPtr; i temNo: INTEGER; VAR item'£ype: INTEGER; VAR item: Handle; VAR box : Rect); PROCEDURE SetDitem (theDialog: DialogPtr; itemNo : INTEGER; itemType: INTEGER; item: Handle; box: Rect); PROCEDURE GetIText (item : Handle; VAR text: Str255); PROCEDURE Set!Text (item: Handle; text: Str255); PROCEDURE SelIText (theDialog: DialogPtr; itemNo: INTEGER; strtSel,endSel: INTEGER); FUNCTION GetAlrtStage INTEGER; [Not in ROM] PROCEDURE ResetAlrtStage; [Not in ROM] Userltem Procedure PROCEDURE Myitem (theWindow: WindowPtr; itemNo: INTEGER); IJI-82 Dialog Manager Summary Sound Procedure PROCEDURE MySound (sound.No : INTEGER) ; FilterProc Function for Modal Dialogs and Alerts FUNCTION MyFilter (theDialog: DialogPtr; VAR theEvent: EventRecord; VAR itemHit: INTEGER) : BOOLEAN; Assembly-Language Information Constants ; Item types ctrlitem .EQU 4 ;add to following four constants btnCtrl .EQU 0 ; s tandard button control chkCtrl .EQU 1 ;standard check box control radCtrl .EQU 2 ;standard radio button control resCtrl .EQU 3 ;control defined in control templat e stat Text .EQU 8 ; static text edit Text .EQU 16 ;editable text (dialog onl y ) icon Item .EQU 32 ;icon picitem .EQU 64 ;QuickDraw picture user Item .EQU 0 ;application-defined item (dialog only ) itemDisable .EQU 128 ;add to any of above to disab le ; Item numbers of OK and Cancel buttons okButton .EQU 1 cancelButton .EQU 2 ; Resource IDs of alert icons stop Icon .EQU 0 note Icon .EQU 1 cautionicon .EQU 2 ; Masks for stages word in alert template volBits .EQU 3 ; s ound number alBit .EQU 4 ;whether to draw box okDismissal .EQU 8 ;item number of default button minus 1 Dialog Manager I!I-83 Inside Macintosh Dialog Record Data Structure dWindow Dialog window items Handle to dialog's item list teHandle Handle to current edi(fext item editField Item number of editText item minus 1 (word) aDefltem Item number of default button (word) dWindLen Size in bytes of dialog record Dialog Template Data Structure dBounds Rectangle that becomes portRect of dialog window's grafPort (8 bytes) dWindProc Window definition ID (word) dVisible Nonzero if dialog window is visible (word) dGoAway Nonzero if dialog window has a go-away region (word) dRefCon Dialog window's reference value (long) ditems Resource ID of dialog's item list (word) dTitle Dialog window's title (preceded by length byte) Alert Template Data Structure aBounds Rectangle that becomes portRect of alert window's grafPort (8 bytes) aitems Resource ID of alert's item list (word) aStages Stages word; information for alert stages Item List Data Structure dlgMaxlndex Number of items minus 1 (word) itmHndl Handie·or procedure pointer for this item itmRect Display rectangle for this item (8 bytes) itmType Item type for this item (byte) itmData Length byte followed by data for this item (data must be even number of bytes) Variables ResumeProc Address of resume procedure DAStrings Handles to ParamText strings (16 bytes) DABeeper Address of current sound procedure DlgFont Font number for dialogs and alerts (word) A Count Stage number (0 through 3) of last alert (word) ANumber Resource ID of last alert (word) 111-84 Dialog Manager Summary DISK DRIVER Constants CONST { Positioning modes fsAtMark 0; {at current sector} fsFromStart 1; {relative to first sect or} fsFrom\1ark 3; {relative to current sector} r dVerify 64; {add to above for read-verify} Data Types TYPE DrvSts = RECORD track : INTEGER; {current track} writeProt : SignedByte; {bit 7=1 if volume is locked} diskinPlace: SignedByte; {disk in place} installed: SignedByte; {drive installed} sides: SignedByte; {bit 7=0 if single- sided drive } qLink: QElemPtr; {next queue entry} qType: INTEGER; {reserved for future use} dQDrive : INTEGER; {drive number } dQRefNum : INTEGER; {driver reference number} dQFSID: INTEGER; {file-system identifier} twoSideFmt: SignedByte; {-1 if two-sided disk} needsFlush: SignedByte; {reserved for future use} diskErrs: INTEGER {error count} END; Routines [Not in ROM] FUNCTION DiskEject (drvNum : INTEGER) : OSErr; FUNCTION SetTagBuffer (buffPtr: Ptr) : OSErr; FUNCTION DriveStatus (drvNum: INTEGER; VAR status : DrvSts) OSErr; Result Codes Name Value Meaning noErr 0 No error nsDrvErr - 56 No such drive paramErr -50 Bad positioning information wPrErr -44 Volume is locked by a hardware setting Disk Driver /1/-85 Inside Macintosh Nam e Value Meani n g firstDskErr -84 First of the range of low-level disk errors sectNFErr -8 1 Can't find sector seekErr -80 Drive error spdAdjErr -79 Can't correctly adjust disk speed twoSideErr - 78 Tried to read side 2 of a disk in a single-sided drive initIWMErr - 77 Can't initialize disk controller chip tkOBadErr - 76 Can't find track 0 cantStepErr -75 Drive error wrUnderrun - 74 Write underrun occurred badDBtSlp -73 Bad data mark badDCksum -72 Bad data mark noDtaMkErr -7 1 Can't find data mark badBtSlpErr -70 Bad address mark badCksmErr -69 Bad address mark dataVerErr -68 Read-verify failed noAdrMkErr -67 Can't find an address mark noNybErr -66 Disk is probably blank offLinErr -65 No disk in drive noDriveErr -64 Drive isn't connected lastDskErr -64 Last of the range of low-level disk errors Assembly-Language Information Constants ; Positioning modes fsAtMark .EQU 0 ;at current sector f sFr omStart .EQU 1 ;relative to first sector fsFromMark .EQU 3 ;relative to current sector rdVerif y . EQU 64 ;add to above for read- verify ; csCode values for Cont r ol/Sta t us calls ejectCode .EQU 7 ;Control call, DiskEject tgBuffCode .EQU 8 ;Control call, SetTagBuffer drvStsCode . EQU 8 ;Status call , DriveStatus Structure of Status Information dsTrack Current track (word) dsWriteProt Bit 7=1 if volume is locked (byte) dsDisklnPlace Disk in place (byte) dslnstalled Drive installed (byte) dsSides Bit 7=0 if single-sided drive (byte) dsQLink Pointer to next queue entry dsDQDrive Drive number (word) III-86 Disk D river Summary dsDQRefNum Driver reference number (word) dsDQFSID File-system identifier (word) dsTwoSideFmt -1 if two-sided disk (byte) dsDiskErrs Error count (word) Equivalent Device Manager Calls Pascal routine Can DiskEject Control with csCode=ejectCode SetTagBuffer Control with csCode=tgBuffCode DriveStatus Status with csCode=drvStsCode, status returned in csParam through csParam+21 Variables BuffgFNum File tags buffer: file number (long) BuffgFFlag File tags buffer: flags (word: bit 1=1 if resource fork) BuffgFBkNum File tags buffer: logical block number (word) BuffgDate File tags buffer: date and time of last modification (long) - Disk Driver III-87 Inside Macintosh DISK INITIALIZATION PACKAGE Routines PROCEDURE DILoad; PROCEDURE DIUnload; FUNCTION DIBadMount (where: Point; evtMessage: LONG INT) INTEGER; FUNCTION DIFormat (drvNum: INTEGER) : OSErr; FUNCTION DIVerify (drvNum: INTEGER) : OSErr; FUNCTION DIZero (drvNum: INTEGER; volName : Str255) OSErr; Result Codes Name Val ue Meanin g badMDBErr -60 Bad master directory block extFSErr -58 External file system firstDskErr -84 First of the range of low-level disk errors ioErr -36 1/0 error lastDskErr -64 Last of the range of low-level disk errors memFul!Err -108 Not enough room in heap zone noErr 0 No error noMacDskErr -57 Not a Macintosh disk nsDrvErr -56 No such drive paramErr -50 Bad drive number vo!OnLinErr -55 Volume already on-line Assembly-Language Information Constants ; Routine selectors di Bad.Mount .EQU 0 d i Load .EQU 2 diUnload .EQU 4 diFormat . EQU 6 di Verify .EQU 8 di Zero . EQU 10 l//-88 Disk Initialization Package Summary Trap Macro Name Paclc2 ' Disk Initialization Package III-89 Inside Macintosh EVENT MANAGER, OPERATING SYSTEM Constants CONST { Event codes } nullEvent O; {null} mouseDown 1; {mouse-down} mouseUp 2; {mouse-up} keyDown 3; (key-down} keyUp 4; (key-up} autoKey 5; (auto-key} updateEvt 6; (update; Toolbox only} diskEvt 7; {disk-inserted} activateEvt 8; {activate ; Toolbox onl y} networkEvt 10; {network} driverEvt 11; (device driver} applEvt 12; (application-defined} app2Evt 13; (application-defined} app3Evt 14; (application- defined} app4Evt 15; {application- defined} ( Masks for keyboard event message } charCodeMask $000000FF; (character c ode} keyCodeMask $0000FFOO; {key code} ( Masks for forming event mask } mDownMask 2; {mouse-down} mUpMask 4; {mouse-up} keyDownMask 8; {key- down} keyUpMask 16; (key-up} autoKeyMask 32; (auto-key} updateMask 64; {update} diskMask 128; (disk-inserted} activMask 256; {activate} networkMask 1024; {network} driverMask 2048; (device driver} applMask 4096; (application-de fined} app2Mask 8192; {application-defined} app3Mask 16384; {application-defined} app4Mask -32768; (application-defined} everyEvent -1 ; {all event types} III-90 Event Manager, Operating System Summary { Modifier flags in event record } activeFlag = l; {set if window being activated} btnState 128; {set if mouse button up} cmdKey 256; {set if Command key down} shif tKey 512; {set if Shift key down} alpha Lock 1024; {set if Caps Lock key down } optionKey 2048; {set if Option key down} { Result codes returned by PostEvent } noErr O; {no error (event posted) } evtNotEnb = 1; {event type not designated in system event mas k } Data Types TYPE EventRecord = RECORD what : INTEGER; {event code} message: LONGINT; {event message} when: LONGINT; {ticks since startup} where: Point; {mouse location } modifiers: INTEGER {modifier flags } END; EvQEl =RECORD qLink: QElemPtr; {next queue entry} qType: INTEGER; {queue type} evtQWhat: INTEGER; {event code} evtQMessage: LONGINT; {event message} evtQWhen: LONGINT; {ticks since startup} evtQWhere: Point; {mouse location } evtQModifiers: INTEGER {modifier flags } END; Routines Posting and Removing Events FUNCTION PostEvent (eventCode: INTEGER; eventMsg: LONGINT) OSErr; PROCEDURE FlushEvents (eventMask,stopMask: INTEGER); Accessing Events FUNCTION GetOSEvent (eventMask: INTEGER; VAR theEvent : EventRecord ) BOOLEAN; FUNCTION OSEventAvail (eventMask: INTEGER; VAR theEvent: EventRecord) BOOLEAN; Event Manager, Operating System /Il-9/ Inside Macintosh Setting the System Event Mask PROCEDURE SetEventMask (theMask: INTEGER) ; [Not in ROM] Directly Accessing the Event Queue FUNCTION GetEvQHdr : QHdrPtr; [Not in ROM] Assembly-Language Information Constants ; Event codes nullEvt .EQU 0 ;null mButDwnEvt . EQU 1 ; mouse-down mButUpEvt .EQU 2 ;mouse-up keyDwnEvt . EQU 3 ;key-down keyUpEvt .EQU 4 ; key- up autoKeyEvt . EQU 5 ;auto-key updatEvt . EQU 6 ; update; Toolbox only diskinsertEvt . EQU 7 ;disk-inserted acti vateEvt . EQU 8 ;activate; Toolbox only networkEvt . EQU 10 ;network ioDrvrEvt . EQU 11 ; device driver applEvt .EQU 12 ;application- defined app2Evt .EQU 13 ;appl ication-defined app3Evt . EQU 14 ;application- defined app4Evt . EQU 15 ; appl ication-defined ; Modifier flags i n event record activeFlag .EQU 0 ;set if window being activated btnState .EQU 2 ; set if mouse button up cm::l.Key .EQU 3 ;set if Comnand key down s hiftKey . EQU 4 ; s et if Shift key down alpha Lock . EQU 5 ; set if Caps Lock key down opti onKey . EQU 6 ; set if Option key down ; Result codes retu rned by PostEvent noErr . EQU 0 ;no err or (event posted) evtNotEnb . EQU 1 ;event type not designat ed in system ; event mask 1//-92 Event Manager, Operating System Summary Event Record Data Structure evtNum Event code (word) evtMessage Event message (long) evtTicks Ticks since startup (long) evtMouse Mouse location (point; long) evtMeta State of modifier keys (byte) evtMBut State of mouse button (byte) evtBlkSize Size in bytes of event record Event Queue Entry Data Structure qLink Pointer to next queue entry qType Queue type (word) evtQWhat Event code (word) evtQMessage Event message (long) evtQWhen Ticks since startup (long) evtQWhere Mouse location (point; long) evtQMeta State of modifier keys (byte) evtQMBut State of mouse button (byte) evtQBlkSize Size in bytes of event queue entry Routines Trap macro On entry On exit PostEvent AO: eventCode (word) DO: result code (word) DO: eventMsg (long) FlushEvents DO: low word: eventMask DO: 0 or event code (word) high word: stopMask GetOSEvent AO: ptr to event record DO: 0 if non-null event, and theEvent -1 if null event (byte) OSEventAvail DO: eventMask (word) Variables SysEvtMask System event mask (word) EventQueue Event queue header (10 bytes) Event Manager, Operating System 111-93 Inside Macintosh EVENT MANAGER, TOOLBOX Constants CONST { Event codes nullEvent O; {null} mouseDown 1; {mouse down} mouseUp 2; {mouse up} keyDown 3; {key- down} keyUp 4; {key-up} autoKey 5; {auto- key} updateEvt 6; {update} diskEvt 7; {disk-inserted} activateEvt 8; {activate} networkEvt 10; {network} driverEvt 11; {device driver} applEvt 12; {application- defined} app2Evt 13; {application- defined} app3Evt 14; {application- defined} app4Evt 15; {application- defined} { Masks for keyboard event message } charCodeMask = $000000FF; {character code } keyCodeMask $0000FFOO; {key code} { Masks for forming event mask } mDownMask 2; {mouse down} mUpMask 4; {mouse up} keyDownMask 8; {key-down} keyUpMask 16; {key-up } autoKeyMask 32; {auto-key} updateMask 64; {update} diskMask 128; {disk-inserted} activMask 256; {activate} networkMask 1024; {network} driverMask 2048; {device driver} applMask 4096; {application-def i ned} app2Mask 8192; {application- defined} app3Ma sk 16384; {application- defined} app4Mask - 32768; {appl ication- defined} everyEvent -1; {all event types} III-94 Event Manager, Toolbox Summary { Modifier flags in event record } activeFlag 1; {set if window being act ivated} btnState 128; {set if mouse button up} cmd.Key 256; {set if Command key down} shift Key 512 ; {set if Shift key down} alpha Lock 1 024; {set if Caps Lock key down} optionKey 2048; {set if Option key down} Data Types TYPE EventRecord = RECORD what: INTEGER; {event code } message: LONG INT; {event message } when: LONG INT; {ticks since startup} where: Point; {mouse location} modifiers: INTEGER {modifier flags} END; KeyMap PACKED ARRAY[0 .. 127] OF BOOLEAN; Routines Accessing Events FUNCTION GetNextEvent (e ventMas k: INTEGER; VAR theEvent: EventRecord) : BOOLEAN; FUNCTION EventAvail (eventMask : INTEGER; VAR theEvent : EventRecord) : BOOLEAN; Reading the Mouse PROCEDURE GetMouse (VAR mouseLoc: Point); FUNCTION Button : BOOLEAN; FUNCTION StillDown BOOLEAN; FUNCTION WaitMouseUp : BOOLEAN; Reading the Keyboard and Keypad PROCEDURE GetKeys (VAR theKeys: KeyMap); Miscellaneous Routines FUNCTION TickCount LONG INT; FUNCTION GetDblTime LONG INT; [Not in ROM] FUNCTION GetCaretTime LONG INT; [Not in ROM] Event Manager, Toolbox 111-95 Inside Macintosh Event Message in Event Record Event type Even t m essage Keyboard Character code and key code in low-order word Activate, update Pointer to window Disk-inserted Drive number in low-order word, File Manager result code in high- order word Mouse-down, Undefined mouse-up, null Network Handle to parameter block Device driver See chapter describing driver Application- Whatever you wish defined Assembly-Language Information Constants ; Event codes nullEvt .EQU 0 ;null mButDwnEvt .EQU 1 ;mouse-down mButUpEvt . EQU 2 ;mouse-up keyDwnEvt . EQU 3 ;key-do wn keyUpEvt . EQU 4 ;key-up autoKeyEvt .EQU 5 ;auto-key updatEvt .EQU 6 ;update disklnsertEvt .EQU 7 ;disk-inserted activateEvt .EQU 8 ;activate net workEvt .EQU 10 ;network ioDrvrEvt . EQU 11 ;device driver applEvt . EQU 12 ;application-defined app2Evt . EQU 13 ;application-de fined app3Evt . EQU 14 ;application-defined app4Evt . EQU 15 ;application-defined ; Modifier flags in event record a ctiveFlag .EQU 0 ;set if window being activated btnState .EQU 2 ; set if mouse button up cmdKey .EQU 3 ;set if Command key down shif tKey . EQU 4 ; set if Shift key down alphaLock .EQU 5 ; set if Caps Lock key d own optionKey .EQU 6 ;set if Option key down 111-96 Event Manager, Toolbox Summary ; Journaling mechanism Control call jPlayCtl . EQU 16 ;journal in playback mode jRecordCtl .EQU 17 ;journal in recording mode jcTickCount .EQU 0 ;journal code for TickCount jcGetMouse .EQU 1 ;journal code for GetMouse jcButton .EQU 2 ;journal code for Button jcGetKeys . EQU 3 ;journal code for Get Keys jcEvent . EQU 4 ;j ournal code for GetNextEven t and EventAvai l Event Record Data Stru cture evtNum Event code (word) evtMessage Event message (long) evtTicks Ticks since startup (long) evtMouse Mouse location (point; long) evtMeta State of modifier keys (byte) evtMBut State of mouse button (byte) evtBlkSize Size in bytes of event record Variables KeyThresh Auto-key threshold (word) KeyRepThresh Auto-key rate (word) WindowList 0 if using events but not windows (long) ScrDmpEnb 0 if GetNextEvent shouldn't process Command-Shift-number combinations (byte) Ticks Current number of ticks since system startup (long) DoubleTime Double-click interval in ticks (long) CaretTime Caret-blink interval in ticks (long) JournalRef Reference number of journaling device driver (word) Journal Flag Journaling mode (word) Event Manager, Toolbox III-97 Inside Macintosh FILE MANAGER Constants CONST { Flags in file information used by the Finder I fHasBundle 8192; {set if file has a bundle} finvisible 16384; {set if file's icon is invisible) fTrash - 3; {file is in Trash window) fDesktop -2; {file is on desktop) fDisk 0; {file is in disk window) { Values for requesting read/write access } fsCurPerm O; {whatever is currently allowed) fsRdPerm 1; {request to read only} fsWrPerm 2; {request to write only) fsRdWrPerm 3; {request to read and write) { Positioning modes } fsAtMark O; {at cu rrent mark} fsFromStart 1; {offset relative to beginning of file} fsFromLEOF 2; {offset relative to logical end-of-file} fsFromMark 3; {offset rel ative to current mark ) rdVerify 64; {add to above for read- verify} Data Types TYPE Finf o = RECORD fdType : OSType; {file type} fdCreator : OSType; {file's creator} fdFlags : INTEGER; {flags} fdLocation : Point ; {file ' s location } fdFldr : INTEGER {file's window} END; ParamBl kType (ioParam, fileParam , volumeParam,cntrlParam); ParmBl kPtr AParamBlockRec; ParamBlockRec RECORD qLink : QEl emPtr; {next queue entry} qType: INTEGER; {queue type) ioTrap: INTEGER; {routine trap} ioCrrdAddr: Ptr; {routine address} ioCompletion : ProcPtr; {completion routine) ioResult: OSErr; {result code} ioNamePtr: StringPtr; {volume or fi le name) ioVRefNum : INTEGER; {volume reference or drive number} I//-98 File Manager Summary CASE ParamBlkType OF ioParam: (ioRefNum: INTEGER; {path reference number } ioVersNum : SignedByte; {version number} ioPermssn: SignedByte; {read/write permission} ioMisc: Ptr; {miscellaneous} ioBuffer: Ptr; {data buffer} ioReqCount: LONGINT; {requested number of bytes } ioActCount: LONGINT; {actual number of bytes } ioPosMode: INTEGER; {positioning mode and newl i ne character } ioPosOffset: LONGI NT); {positioning offset} fileParam: (ioFRefNum: INTEGER; {path referenc e number } ioFVersNum: SignedByte; {version number} fillerl: SignedByte; {not used} ioFDirindex: INTEGER; {s equence number of file } ioFlAttrib: SignedByte; {file attribu tes} ioFlVersNum: SignedByte {version number} ioFlFndrinfo: Finfo ; {information used by the Finder} ioFlNum: LONGINT; {file number} ioFlStBlk: INTEGER; {first allocation b l ock o f data fork} ioFlLgLen: LONGINT; {logical end- of- fi l e of data fork} ioFlPyLen: LONGINT; {physical end-o f - file of data fork} ioFlRStBlk: INTEGER; {first allocation block of resource ( fork} ioFlRLgLen : LONGINT; {logical end-of- file of resource fork } ioFlRPyLen: LONG INT; {physical end- of-fi l e of resource } { fork} ioFlCrDat: LONG INT; {date and time of creation} ioFlMdDat: LONGINT); (date and time of last modification } volumeParam : (filler2: LONG INT; {not used} ioVolindex: INTEGER; (volume index} ioVCrDate: LONG INT; {date and time of initia lizat i on } ioVLsBkUp: LONG INT; {date and time of last backup } ioVAtrb: INTEGER; {bit 1 5=1 if volume locked} ioVNmFls: INTEGER; {number of files in directory} ioVDirSt: INTEGER; {first block of directory } ioVBlLn: INTEGER; {length of directory i n blocks} ioVNmAlBlks: INTEGER; {number of allocation blocks} ioVAlBlkSiz: LONGINT; {size of allocation blocks} ioVClpSiz: LONGINT; {number of bytes to allocate } ioAlBlSt: INTEGER; {first allocation block i n block map } ioVNxtFNum : LONGINT; {next unused file number } ioVFrBlk: INTEGER); {number of unused allocation blocks} cntrlParam: {used by Devi ce Manager} END; File Manager III-99 Inside Macintosh VCB RECORD qLink: QElemPtr; {next queue entry} qType: INTEGER; {queue type} vcbFlags: INTEGER; {bit 15=1 if dirty} vcbSigWord: INTEGER; {always $D2D7} vcbCrDate: LONGINT; {date and time of initialization} vcbLsBkUp: LONGINT; {date and time of last backup} vcbAtrb: INTEGER; {volume attributes} vcbNmFls: INTEGER; {number of files in directory} vcbDirSt: INTEGER; {first block of directory} vcbBlLn: INTEGER; {length of directory in b locks} vcbNrnBlks: INTEGER; {number of allocation blocks} vcbAlBl kSiz: LONGINT; {size of allocation blocks} vcbClpSiz: LONGINT; {number of bytes to all ocate} vcbAlBl St: INTEGER; {first allocation block in block map } vcbNxtFNum : LONGINT; {next unused file number} vcbFreeBks: INTEGER; {number of unused allocation blocks} vcbVN: STRING[27]; {volume name} vcbDrvNum INTEGER; {drive number} vcbDRefNum: INTEGER; {driver reference number} vcbFSID: INTEGER; {file-system identifier} vcbVRefNum: INTEGER; {volume reference number} vcbMAdr: Ptr; {pointer to block map} vcbBufAdr: Ptr; {pointer to volume buffer} vcbMLen: INTEGER; {number of bytes in block map} vcbDirindex: INTEGER; {us ed internally) vcbDirBlk: INTEGER {used internally} END; DrvQEl = RECORD qLink: QElemPtr; {next queue entry } qType: INTEGER; {queue type} dQDrive: INTEGER; {drive number} dQRefNum: INTEGER; {driver reference number} dQFSID: INTEGER; {file-system identifier } dQDrvSize : INTEGER {number of logical blocks} END; High-Level Routines [Not in ROM] Accessing Volumes FUNCTION GetVInfo (drvNum: INTEGER; volName: StringPtr; VAR vRefNum: INTEGER; VAR freeBytes: LONGINT) : OSErr ; FUNCTION GetVRefNum (pathRefNum: INTEGER; VAR vRefNum: INTEGER) : OSErr; FUNCTION GetVol (volName : StringPtr; VAR vRefNum: INTEGER) : OSErr; FUNCTION SetVol (volName : StringPtr; vRefNum : INTEGER) OSErr; FUNCTION FlushVol (volName: StringPtr; vRefNum: INTEGER) OSErr; FUNCTION UnmountVol (volName : StringPtr; vRefNum: INTEGER) OSErr; FUNCTION Eject (volName : StringPtr; vRefNum: INTEGER) OSErr; ///-]{)() File Manager Summary Accessing Files FUNCTION Create (fileName: Str255; vRefNum: INTEGER; creator: OS Type; fileType: OSType) : OSErr; FUNCTION FSOpen (fileName: Str255; vRefNum: INTEGER; VAR refNum: INTEGER) : OSErr; FUNCTION OpenRF (fileName: Str255; vRefNum: INTEGER; VAR refNum: INTEGER) : OSErr; FUNCTION FSRead (r efNum: INTEGER; VAR count: LONGINT; buffPtr: Ptr) OSErr; FUNCTION FSWrite (refNum: INTEGER; VAR count: LONGINT; buffPtr: Ptr) OSErr; FUNCTION GetFPos (refNum : INTEGER; VAR filePos: LONGINT) : OSErr; FUNCTION SetFPos (refNum: INTEGER; posMode: INTEGER; posOff: LONGINT) OSErr; FUNCTION GetEOF (refNum : INTEGER; VAR l ogEOF: LONGINT) : OSErr; FUNCTION SetEOF (refNum: INTEGER; logEOF: LONGINT) : OSErr; FUNCTION Allocate (refNum: INTEGER; VAR count: LONGINT) : OSErr; FUNCTION FSClose (r efNum: INTEGER) : OSErr; Chang ing Information About Files FUNCTION GetFinfo (f ileName: Str255; vRefNum : INTEGER; VAR fndrinfo: Finfo) : OSErr; FUNCTION SetFinfo (fileName: Str255; vRefNum: INTEGER; fndrinfo: Finfo): OSErr; FUNCTION SetFLock (fileName: Str255; vRefNum: INTEGER) : OSErr; FUNCTION RstFLock (fileName : Str255; vRefNum: INTEGER) : OSErr; FUNCTION Rename (oldName: Str255; vRefNum: INTEGER; newName : Str255) OSErr; FUNCTION FSDelete (fileName: Str255; vRefNum: INTEGER) : OSErr; Low-Level Routines Initializing the File 1/0 Queue PROCEDURE FinitQueue; Accessing Volumes FUNCTION PBMountVol (paramBlock: ParmBlkPtr) OSErr; t - 16 ioResult word H 22 ioVRefNum word File Manager III-JOI Inside Macintosh FUNCTION PBGetVInfo (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer f- 16 ioResult word H 18 ioNamePtr pointer H 22 ioVRefNum word ~ 28 ioVollndex word f- 30 ioVGDate long word f- 34 ioVLsBkUp long word f- 38 ioVAtrb word f- 40 ioVNmAs word f- 42 ioVDirSt word f- 44 ioVBILn word f- 46 ioVNmAIBlks word f- 48 iov AlBlkSiz long word f- 52 ioVClpSiz long word f- 56 ioAIBISt word f- 58 ioVNxtFNum long word f- 62 ioVFrBlk word FUNCTION PBGetVol (paramBlock: ParmBlkPtr; a sync : BOOLEAN) OSErr; ~ 12 ioCompletion pointer f- 16 ioResult word f- 18 ioNamePtr pointer f- 22 ioVRefNum word FUNCTION PBSetVol (paramBlock: ParmBlkPtr; async : BOOLEAN) OSErr; ~ 12 ioCompletion pointer f- 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word FUNCTION PBFlushVol (paramBlock: ParmBlkPtr; async : BOOLEAN) OSErr; ~ 12 ioCompletion pointer f- 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word FUNCTION PBUrunountVol (paramBlock : ParmBlkPtr) OSErr; f- 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word FUNCTION PBOffLine (paramBlock: ParmBlkPtr) OSErr ; ~ 12 ioCompletion pointer f- 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word III-102 File Manager Summary FUNCTION PBEject (paramBlock: ParmBlkPtr) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePt pointer ~ 22 ioVRetNum word Accessing Files FUNCTION PBCreate (paramBlock : ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 26 ioFVersNum byte FUNCTION PBOpen (par amBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRetNum word ~ 24 ioRefNum word ~ 26 ioVersNum byte ~ 27 ioPennssn byte ~ 28 ioMisc pointer FUNCTION PBOpenRF (paramBlock: ParmBlkPtr; a sync: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 24 ioRetNum word ~ 26 ioVersNum byte ~ 27 ioPennssn byte ~ 28 ioMisc pointer FUNCTION PBRead (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 24 ioRetNum word ~ 32 ioBuffer pointer ~ 36 ioReqCount longword ~ 40 ioActCount long word ~ 44 ioPosMode word H 46 ioPosOffset long word File Manager ll/-/03 Inside Macintosh FUNCTION PBWrite (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word ---7 32 ioBuffer pointer ---7 36 ioReqCount long word t- 40 ioActCount long word ---7 44 ioPosMode word H 46 ioPosOffset long word FUNCTION PBGetFPos (pararnBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word t- 36 ioReqCount long word t- 40 ioActCount long word t- 44 ioPosMode word t- 46 ioPosOffset long word FUNCTION PBSetFPos (paramBlock: ParmBlkPtr; async: BOOLEAN ) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word ---7 44 ioPosMode word H 46 ioPosOffset long word FUNCTION PBGetEOF (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word t- 28 ioMisc long word FUNCTION PBSetEOF (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word ---7 28 ioMisc long word FUNCTION PBAllocate (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word ---7 36 ioReqCount long word t- 40 ioActCount long word FUNCTION PBFlushFile (pararnBlock: ParmBlkPtr; async: BOOLEAN) OSErr; ---7 12 ioCompletion pointer t- 16 ioResult word ---7 24 ioRefNum word III-104 File Manager Summary FUNCTION PBClose (pararnBlock: PannBlkPtr; async : BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 24 ioRefNurn word Changing Informati on Abou t Files FUNCTION PBGetFinf o (pararnBlock: ParrnBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word H 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 24 ioFRefNum word ~ 26 ioFVersNum byte ~ 28 ioFDirlndex word ~ 30 ioFIAttrib byte ~ 31 ioFIVersNurn byte ~ 32 ioFIFndrlnfo 16 bytes ~ 48 ioFINum long word ~ 52 ioFIStBlk word ~ 54 ioFILgLen long word ~ 58 ioFlPyLen long word ~ 62 ioFIRStBlk word ~ 64 ioFIRLgLen long word ~ 68 ioFIRPyLen long word ~ 72 ioFICrDat long word ~ 76 ioFIMdDat long word FUNCTION PBSetFinfo (pararnBlock : PannBlkPtr ; a sync: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 26 ioFVersNum byte ~ 32 ioFIFndrlnfo 16 bytes ~ 72 ioFICIDat long word ~ 76 ioFIMdDat long word FUNCTION PBSetFLock (pararnBlock : PannBlkPtr; async : BOOLEAN) OSEr r; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 26 ioFVersNum byte FUNCTION PBRstFLock (pararnBlock : PannBlkPtr; async: BOOLEAN) OSErr ; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 26 ioFVersNum byte File Manager III-105 Inside Macintosh FUNCTION PBSetFVers (paramBlock: ParmBlkPtr; async : BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNurn word ~ 26 ioVersNurn byte ~ 28 ioMisc byte FUNCTION PBRename (paramBlock : ParmBlkPtr; async: BOOLEAN) OSErr; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNurn word ~ 26 ioVersNurn byte ~ 28 ioMisc pointer FUNCTION PBDelete (paramBlock: ParmBlkPtr; async: BOOLEAN) OSErr ; ~ 12 ioCompletion pointer ~ 16 ioResult word ~ 18 ioNamePtr pointer ~ 22 ioVRefNum word ~ 26 ioFVersNurn byte Accessing Queues [Not in ROM] FUNCTION GetFSQHdr QHdrPtr; FUNCTION GetVCBQHdr QHdrPtr; FUNCTION GetDrvQHdr QHdrPtr; Result Codes Name Value Meaning badMDBErr -60 Master directory block is bad; must reinitialize volume bdNamErr - 37 Bad file name or volume name (perhaps zero-length) dirFulErr - 33 File directory full dskFulErr -34 All allocation blocks on the volume are full dupFNErr -48 A file with the specified name and version number already exists eofErr -39 Logical end-of-file reached during read operation extFSErr -58 External file system; file-system identifier is nonzero, or path reference number is greater than 1024 fBsyErr -47 One or more files are open fLckdErr -45 File locked fntErr -43 File not found fnOpnErr - 38 File not open III-106 File Manager Summary Name Value Meaning fsRnErr -59 Problem during rename gfpErr -52 Error during GetFPos ioErr -36 IJO error memFullErr -108 Not enough room in heap zone noErr 0 No error noMacDskErr -57 Volume lacks Macintosh-format directory nsDrvErr -56 Specified drive number doesn't match any number in the drive queue nsvErr -35 Specified volume doesn't exist opWrErr -49 The read/write permission of only one access path to a file can allow writing paramErr -50 Parameters don't specify an existing volume, and there's no default volume permErr -54 Attempt to open locked file for writing posErr -40 Attempt to position before start of file rfNumErr -51 Reference number specifies nonexistent access path unfoErr -42 Too many files open volOftLinErr -53 Volume not on-line volOnLinErr -55 Specified volume is already mounted and on-line vLckdErr -46 Volume is locked by a software flag wrPerrnErr -61 Read/write permission doesn't allow writing wPrErr -44 Volume is locked by a hardware setting Assembly-Language Information Constants ; Flags in file information used by the Finder fHasBundle .EQU 13 ;set if file has a bundle finvisible .EQU 14 ;set if file's icon is invisible ; Flags in trap words asnycTrpBit .EQU 10 ;set for an asynchronous call noQueueBit .EQU 9 ;set for immediate execution File Manager III-107 Inside Macintosh ; Values for requesting read/write access fsCurPerm .EQU 0 ;whatever is currently allowed fsRdPerrn .EQU 1 ;request to read only fsWrPerm .EQU 2 ;request to write only fsRdWrPerrn .EQU 3 ;request to read and write ; Positioning modes fsAtMark .EQU 0 ;at current mark fsFromStart .EQU 1 ;offset relative to beginning of file fsFrornLEOF .EQU 2 ;offset relative to logical end-of-file fsFromMark .EQU 3 ;offset relative to current mark rdVerify .EQU 64 ;add to above for read- verify Structure of File Informati on Used by the Finder fdType File type (long) fdCreator File's creator (long) fdFlags Flags (word) fdLocation File's location (point; long) fdFldr File's window (word) Standard Parameter Block Data Structure qLink Pointer to next queue entry qType Queue type (word) ioTrap Routine trap (word) ioCmdAddr Routine address ioCompletion Address of completion routine ioResult Result code (word) ioFileName Pointer to file name (preceded by length byte) ioVNPtr Pointer to volume name (preceded by length byte) ioVRefNum Volume reference number (word) ioDrvNum Drive number (word) 1/0 Para meter Blo ck Data Structure ioRefNum Path reference number (word) ioFileType Version number (byte) ioPermssn Read/write permission (byte) ioNewName Pointer to new file or volume name for Rename ioLEOF Logical end-of-file for SetEOF (long) ioOwnBuf Pointer to access path buffer ioNewType New version number for SetFilType (byte) ioBuffer Pointer to data buffer ioReqCount Requested number of bytes (long) ioActCount Actual number of bytes (long) ioPosMode Positioning mode and newline character (word) III-108 File Manager Summary ioPosOffset Positioning offset (long) ioQElSize Size in bytes of IJO parameter block Structure of File Information Parameter Block ioRefNum Path reference number (word) ioFileType Version number (byte) ioFDirlndex Sequence number of file (word) ioFlAttrib File attributes (byte) ioFFlType Version number (byte) ioFlUsrWds Information used by the Finder ( 16 bytes) ioFFlNum File number (long) ioFlStBlk First allocation block of data fork (word) ioFlLgLen Logical end-of-file of data fork (long) ioFlPyLen Physical end-of-file of data fork (long) ioFlRStBlk First allocation block of resource fork (word) ioFlRLgLen Logical end-of-file of resource fork (long) ioFlRPyLen Physical end-of-file of resource fork (long) ioFlCrDat Date and time of creation (long) ioFlMdDat Date and time of last modification (long) ioFQElSize Size in bytes of file information parameter block Structure of Volume Information Parameter Block ioVollndex Volume index (word) ioVCrDate Date and time of initialization (long) ioVLsBkUp Date and time of last backup (long) ioVAtrb Volume attributes (word) ioVNmFls Number of files in directory (word) ioVDirSt First block of directory (word) ioVBlLn Length of directory in blocks (word) io VNmAlBlks Number of allocation blocks on volume (word) io VAlBlkSiz Size of allocation blocks (long) ioVClpSiz Number of bytes to allocate (long) ioAlBlSt First allocation block in block map (word) ioVNxtFNum Next unused file number (long) ioVFrBlk Number of unused allocation blocks (word) ioVQElSize Size in bytes of volume information parameter block Volume Information Data Structure drSigWord Always $D2D7 (word) drCrDate Date and time of initialization (long) drLsBkUp Date and time oflast backup (long) drAtrb Volume attributes (word) drNmFls Number of files in directory (word) drDirSt First block of directory (word) drBlLn Length of directory in blocks (word) drNmAlBlks Number of allocation blocks on volume (word) drAlBlkSiz Size of allocation blocks (long) File Manager Ill-109 Inside Macintosh drOpSiz Number of bytes to allocate (long) drAlBlSt First allocation block in block map (word) drNxtFNum Next unused file number (long) drFreeBks Number of unused allocation blocks (word) drVN Volume name preceded by length byte (28 bytes) File Directory Entry Data Structure fl Flags Bit 7=1 if entry used; bit 0= 1 if file locked (byte) flTyp Version number (byte) flUsrWds Information used by the Finder (16 bytes) f!FlNum File number (long) flStBlk First allocation block of data fork (word) f!LgLen Logical end-of-file of data fork (long) flPyLen Physical end-of-file of data fork (long) flRStBlk First allocation block of resource fork (word) flRLgLen Logical end-of-file of resource fork (long) flRPyLen Physical end-of-file of resource fork (long) flCrDat Date and time file of creation (long) flMdDat Date and time of last modification (long) flNam File name preceded by length byte Volume Control Block Data Structure qLink Pointer to next queue entry qType Queue type (word) vcbFlags Bit 15=1 if volume control block is dirty (word) vcbSigWord Always $D2D7 (word) vcbCrDate Date and time of initialization (word) vcbLsBkUp Date and time of last backup (long) vcbAtrb Volume attributes (word) vcbNmFls Number of files in directory (word) vcbDirSt First block of directory (word) vcbBlLn Length of directory in blocks (word) vcbNmBlks Number of allocation blocks on volume (word) vcbAIBlkSiz Size of allocation blocks (long) vcbClpSiz Number of bytes to allocate (long) vcbAIBlSt First allocation block in block map (word) vcbNxtFNum Next unused file number (long) vcbFreeBks Number of unused allocation blocks (word) vcbVN Volume name preceded by length byte (28 bytes) vcbDrvNum Drive number of drive in which volume is mounted (word) vcbDRefNum Driver reference number of driver for drive in which volume is mounted (word) vcbFSID File-system identifier (word) vcbVRefNum Volume reference number (word) vcbMAdr Pointer to volume block map vcbBufAdr Pointer to volume buffer vcbMLen Number of bytes in volume block map (word) III-110 File Manager Summary File Control Block Data Structure fcbFINum File number (long) fcbMdRByt Flags (byte) fcbTypByt Version number (byte) fcbSBlk First allocation block of file (word) fcbEOF Logical end-of-file (long) fcbPLen Physical end-of-file (long) fcbCrPs Mark (long) fcbVPtr Pointer to volume control block (long) fcbBfAdr Pointer to access path buffer (long) Drive Queue Entry Data Structure qLink Pointer to next queue entry qType Queue type (word) dQDrive Drive number (word) dQRefNum Driver reference number (word) dQFSID File-system identifier (word) dQDrvSize Number of logical blocks (word) Macro Names Pascal name Macro name FlnitQueue _lnitQueue PB MountVol MountVol PBGetVInfo -GetVollnfo PBGetVol -GetVol PBSetVol SetVol PBFlushVol FlushVol PBUnmountVol UnmountVol PBOffLine OffLine PB Eject _Eject PBCreate Create PB Open Open PBOpenRF -OpenRF PB Read Read PB Write Write PBGetFPos GetFPos PBSetFPos SetFPos PBGetEOF GetEOF PBSetEOF SetEOF PB Allocate Allocate PBFlushFile FlushFile PB Close -Close PBGetFlnfo - GetFilelnfo PBSetFlnfo SetFilelnfo PBSetFLock - SetFilLock PBRstFLock RstFilLock File Manager /11-111 Inside Macintosh PBSetFVer.; _ SetFilType PB Rename Rename PB Delete Delete Variables FSQHdr File 1/0 queue header (10 bytes) VCBQHdr Volume-control-block queue header (10 bytes) DefVCBPtr Pointer to default volume control block FCBSPtr Pointer to file-control-block buffer DrvQHdr Drive queue header (10 bytes) ToExtFS Pointer to external file system II/-112 File Manager Summary FONT MANAGER Constants CONST { Font numbers ) systemFont O; {system font) applFont 1; {application font) newYork 2; geneva 3; monaco 4; venice 5; london 6; a t hens 7; sanFran 8; toronto 9; cairo 11; losAngeles 12; times 20; helvetica 21; courier 22; symbol 23; taliesin 24; { Special characters commandMark $11; {Command key symbol) checkMark $12 ; {check mark) diamondMark $1 3; {diamond symbol) appl eMark $1 4; {apple symbol) { Font types ) propFont $9000; {proportional font) fixedFont $BOOO ; {fixed- width font) fontWid $ACBO; {font width data) Data Types TYPE FMinput = PACKED RECORD family : INTEGER; {font number) size: INTEGER; {font size) face : Style; {character style) needBits: BOOLEAN; {TRUE if drawing) device: INTEGER; {device- specific information) numer: Point; {numerators of scaling factor s} denom: Point {denominators of scaling factors} END; Font Manager III-113 Inside Macintosh FMOutPtr = "FMOutput; FMOutput = PACKED RECORD errNum: INTEGER; {not used} fontHandle: Handle; {handle to font record} bold: Byte; {bold factor } i talic: Byte; {italic factor} ulOffset: Byte; {underline offset} ulShadow: Byte; {underline shadow} ulThick: Byte; {underline thickness} shadow: Byte; {shadow fact or} extra: SignedByte; {width of style } ascent: Byte; {ascent} descent : Byte; {descent} widMax: Byte; {maximum character width} leading: SignedByte; {leading} unused: Byte; {not used} numer: Point; {numerators of scaling factors} denom: Point {denominators of scaling factors} END; FontRec = RECORD fontType: INTEGER; {font type} firstChar: INTEGER; {ASCII code of first character } lastChar: INTEGER; {ASCII code of last character} widMax: INTEGER; {maximum character width} kernMax: INTEGER; {negative of maximum character kern} nDescent: INTEGER; {negative of descent} fRectWidth: INTEGER; {width of font rectangle } fRectHeight: INTEGER; {height of font rectangle} owTLoc: INTEGER; {offset to offset/width table} ascent: INTEGER; {ascent} descent: INTEGER; {descent} leading: INTEGER; {leading} rowWords : INTEGER; {row width of bit image I 2) { bitimage: ARRAY[l. . rowWords,1. .fRectHeight ] OF INTEGER; {bit image} { locTable: ARRAY [firstChar .. lastChar+2] OF INTEGER; {location table} { owTable: ARRAY[firstChar .. lastChar+2] OF INTEGER; {offset/width table} END; Routines Initializing the Font Manager PROCEDURE InitFonts; 111-114 Font Manager Summary Getting Font Information PROCEDURE GetFontNarne (fontNum: INTEGER; VAR theName: Str255); PROCEDURE GetFNum (fontName: Str255; VAR theNum : INTEGER); FUNCTION RealFont (fontNum : INTEGER; size: I NTEGER) : BOOLEAN; Keeping Fonts in Memory PROCEDURE SetFontLock (l ockFlag : BOOLEAN) ; Advanced Routine FUNCTI ON FMSwapFont (inRec: FMinput) : FMOutPt r ; Assembly-Language Information Constants ; Font numbers sysFont . EQU 0 ; system font appl Font . EQU l ; appl ication font newYork .EQU 2 geneva . EQU 3 monaco . EQU 4 venice . EQU 5 london . EQU 6 a thens .EQU 7 sanFran . EQU 8 toronto . EQU 9 cairo . EQU 11 losAngeles .EQU 12 times .EQU 20 helvetica .EQU 21 courier .EQU 22 symbol .EQU 23 ta l ies in .EQU 24 i Special characters commandMark . EQU $11 ; Command key symbol checl=0, function result (long) if <0, result code (word) _SetHandleSize AO: h (handle) DO: result code (word) DO: newSize (long) HandleZone AO: h (handle) AO: function result (ptr) DO: result code (word) RecoverHandle AO: p (ptr) AO: function result (handle) DO: unchanged ReallocHandle AO: h (handle) DO: result code (word) DO: logicalSize (long) NewPtr DO: logicalSize (long) AO: function result (ptr) DO: result code (word) _DisposPtr AO: p (ptr) DO: result code (word) GetPtrSize AO: p (ptr) DO: if >=0, function result (long) if <0, result code (word) SetPtrSize AO: p (ptr) DO: result code (word) DO: newSize (long) PtrZone AO: p (ptr) AO: function result (ptr) DO: result code (word) FreeMem DO: function result (long) MaxMem DO: function result (long) AO: grow (long) _ CompactMem DO: cbNeeded (long) DO: function result (long) ResrvMem DO: cbNeeded (long) DO: result code (word) _PurgeMem DO: cbNeeded (long) DO: result code (word) _Empty Handle AO: h (handle) AO: h (handle) DO: result code (word) HLock AO: h (handle) DO: result code (word) HUnlock AO: h (handle) DO: result code (word) _HPurge AO: h (handle) DO: result code (word) _HNoPurge AO: h (handle) DO: result code (word) SetGrowZone AO: growZone (ptr) DO: result code (word) BlockMove AO: sourcePtr (ptr) DO: result code (word) A 1: destPtr (ptr) DO: byteCount (long) ///-128 Memory Manager Summary Variables DefltStack Default space allotment for stack (long) MinStack Minimum space allotment for stack (long) MemTop Address of end of RAM (on Macintosh XL, end of RAM available to applications) ScrnBase Address of main screen buffer BufPtr Address of end of jump table CurrentA5 Address of boundary between application globals and application parameters CurStackBase Address of base of stack; start of application globals ApplLimit Application heap limit HeapEnd Address of end of application heap zone ApplZone Address of application heap zone SysZone Address of system heap zone TheZone Address of current heap zone GZRootHnd Handle to relocatable block not to be moved by grow zone function Memory Manager 1/1-129 Inside Macintosh MENU MANAGER Constants CONST { Value indicating item has no mark } noMark = 0; { Messages to menu definition procedure mDrawMsg O; {draw the menu} mChooseMsg 1; {tell which item was chosen and highlight i t} mSizeMsg 2; {calculate the menu's dimensions} { Resource ID of standard menu definition procedure } textMenuProc = O; Data Types TYPE MenuHandle "MenuPtr; MenuPtr "Menuinfo; Menuinfo RECORD menuID: INTEGER; {menu ID} menuWidth: INTEGER; {menu width in pixels} menuHeight: INTEGER; {menu height in pixels} menuProc: Handle; {menu definition procedure} enableFlags: LONGINT; {te l ls if menu or items are { enabled } menuData: Str255 {menu title (and other data)} END; Routines Initialization and Allocation PROCEDURE InitMenus; FUNCTION NewMenu (menuID : INTEGER; menuTitle : Str255) MenuHandle; FUNCTION GetMenu (resourceID: INTEGER) : MenuHandle; PROCEDURE DisposeMenu (theMenu: MenuHandle); Forming the Menus PROCEDURE AppendMenu (theMenu: MenuHandle; data : Str255); PROCEDURE AddResMenu (theMenu: MenuHandle; theType: ResType); PROCEDURE InsertResMenu (theMenu : MenuHandle; theType : ResType; afteritem: INTEGER); 111-130 Menu Manager Summary Forming the Menu Bar PROCEDURE InsertMenu (theMenu: MenuHandle; beforeID: INTEGER); PROCEDURE DrawMenuBar; PROCEDURE DeleteMenu (menuID : INTEGER); PROCEDURE ClearMenuBar; FUNCTION GetNewMBar (menuBarID : INTEGER) Handle ; FUNCTION GetMenuBar : Handle; PROCEDURE SetMenuBar (menuList: Handle); Choosing From a Menu FUNCTION MenuSelect (startPt: Point) : LONGI NT; FUNCTION MenuKey (ch: CHAR) : LONGINT; PROCEDURE HiliteMenu (menuID : INTEGER); Controlling the Appearance of Items PROCEDURE Set Item (theMenu: MenuHandle; item : INTEGER; itemString: Str255 ); PROCEDURE Getitem (theMenu: MenuHandle; item: INTEGER; VAR itemString : Str255); PROCEDURE Disable Item (theMenu : MenuHandle; item : INTEGER); PROCEDURE Enable Item (theMenu: MenuHandle; item: INTEGER); PROCEDURE Checkitem (t heMenu : MenuHandle; item: INTEGER; checked: BOOLEAN); PROCEDURE SetitemMark (theMenu: MenuHandle; item: INTEGER; markChar: CHAR); PROCEDURE GetitemMark (theMenu: MenuHandle; item: INTEGER; VAR markChar: CHAR); PROCEDURE Setitemicon (t heMenu : MenuHandle; item: INTEGER; icon : Byte); PROCEDURE Getitemicon (theMenu : MenuHandle; item : I NTEGER; VAR icon: Byte); PROCEDURE SetitemStyle (theMenu: MenuHandle; item : INTEGER; chStyle: Style); PROCEDURE GetitemStyle (theMenu : MenuHandle; item: INTEGER; VAR chStyle: Style); Miscellaneous Routines PROCEDURE CalcMenuSize (theMenu : MenuHandle) ; FUNCTION CountMitems (theMenu: MenuHandle) : INTEGER; FUNCTION GetMHandle (menu ID : INTEGER) : MenuHandle; PROCEDURE FlashMenuBar (menu ID: INTEGER); PROCEDURE SetMenuFlash (count: INTEGER); Menu Manager 11/-131 Inside Macintosh Meta-Characters for AppendMenu Meta-character Usage or Return Separates multiple items /\ Followed by an icon number, adds that icon to the item Followed by a character, marks the item with that character < Followed by B, I, U, 0, or S, sets the character style of the item I Followed by a character, associates a keyboard equivalent with the item ( Disables the item Menu Definition Procedure PROCEDURE MyMenu (message: INTEGER; theMenu : MenuHandle; VAR menuRect : Rect; hitPt: Point; VAR whichitem: I NTEGER); Assembly-Language Information Constants ; Value indicating item has no mark noMark .EQU 0 ; Messages to menu definition procedure mDrawMsg . EQU 0 ;draw the menu rrChooseMsg . EQU 1 ;tell which item was chosen and high light it mSizeMsg .EQU 2 ; calculate the menu·' s dimensions ; Resource ID of standard menu definition procedure textMenuProc .EQU 0 Menu Record Data Structure menuID Menu ID (word) menuWidth Menu width in pixels (word) menuHeight Menu height in pixels (word) menuDetHandle Handle to menu definition procedure menuEnable Enable flags (long) menuData Menu title (preceded by length byte) followed by data defining the items menuBlkSize Size in bytes of menu record except menuData field III-132 MenuManager Summary Special Macro Names Pascal name Macro name DisposeMenu _DisposMenu Getltemlcon _ Getltmlcon GetltemMark GetltmMark GetltemStyle _ GetltmStyle GetMenu GetRMenu Seti ternIcon Setltmlcon SetltemMark SetltmMark SetltemStyle _ SetltmSty le SetMenuFlash SetMFlash Variables MenuList Handle to current menu list MBarEnable Nonzero if menu bar belongs to a desk accessory (word) MenuHook Address of routine called repeatedly during MenuSelect MBarHook Address of routine called by MenuSelect before menu is drawn (see below) TheMenu Menu ID of currently highlighted menu (word) MenuFlash Count for duration of menu item blinking (word) MBarHook routine On entry stack: pointer to menu rectangle On exit DO: 0 to continue MenuSelect 1 to abort MenuSelect MenuManager III-133 Inside Macintosh PACKAGE MANAGER Constants CONST { Resource IDs for packages } dskinit 2; {Di sk Initialization} stdFile 3; {Standard File} flPoint 4; {Floating-Point Arithmetic } trFunc 5; {Transcendental Functions } intUtil 6; {International Utilities} bdConv 7; {Binary-Decimal Conversion} Routines PROCEDURE I nitPack (packID : INTEGER); PROCEDURE InitAllPacks; Assembly-Language Information Constants ; Resource IDs for packages dskinit .EQU 2 ; Disk Initialization stdFile .EQU 3 ;Standard File flPoint .EQU 4 ;Floating-Point Arithmetic trFunc .EQU 5 ;Transcendental Functions intUtil .EQU 6 ;International Utilities bdConv .EQU 7 ;Binary-Decimal Conversion Trap Macros for Packages Disk Initialization Pack2 Standard File Pack3 Floating-Point Arithmetic Pack4 (synonym: FP68K) Transcendental Functions Pack5 (synonym: .=Elems68K) International Utilities -Pack6 Binary-Decimal Conversion Pack7 III-134 PackageManager Summary PRINTING MANAGER Constants • CONST { Printing methods bDraftLoop 0; {draft printing} bSpoolLoop l; {spool printing} { Printer specification in prStl field of print record } bDevCitoh 1; {Imagewriter printer} bDevLaser 3; {LaserWriter printer} { Maximum number of pages in a spool file iPFMaxPgs = 128; { Result codes noErr O; {no error} iPrSavPFil -1; {saving spool file} controlErr -17; {unimplemented control instruction} iIOAbort -27; {I/0 abort error} iMemFullErr -108; {not enough room in heap zone} iPrAbort 128; {application or user requested abort} { PrCtlCall parameters iPrDevCtl 7; {printer control} lPrReset $00010000; {reset printer} lPrLineFeed $00030000; {carriage return only} lPrLFSixth $0003FFFF; {standard 1/6-inch line feed} lPrPageEnd $00020000; {end page} iPrBitsCtl 4; {bit map printing} lScreenBits 0; {default for printer} lPaintBits 1; {square dots (72 by 72)} iPrIOCtl 5; {text streaming} { Printer Driver information } sPrDrvr '.Print'; {Printer Driver resource name} iPrDrvrRef -3; {Printer Driver reference number} Printing Manager lll-135 Inside Macintosh Data Types TYPE TPPrPort "TPrPort; TPrPort RECORD gPort: GrafPort; {grafPort to draw in} {more fields for internal use} END; THPrint "TPPrint; TPPrint "TPrint; TPrint RECORD iPrVersion : INTEGER; {Printing Manager version} prinfo: TPrinfo; {printer information subrecord} rPaper: Rect; {paper rectangle} prStl : TPrSt l ; {additional device information} prinfoPT: TPrinfo; {used i nternally} prXInfo: TPrXInfo; {additional device information} prJob: TPrJob; {job subrecord} printX: ARRAY[l .. 19) OF INTEGER {not used} END; TPrinfo RECORD iDev: INTEGER; {used internally} iVRes: INTEGER; {vertical resolution of p rinte r} iHRes: INTEGER; {horizontal resolution of printer} rPage: Rect {page rectangle} END; TPrJob = RECORD iFstPage: INTEGER; {first page to print} iLstPage: INTEGER; {last page to print} iCopies : INTEGER; {number of copies} bJDocLoop : SignedByte; {printing method} fFromUsr: BOOLEAN; {used internally} pidleProc : ProcPtr; {background procedure} pFileName: StringPtr; {spool file name } iFileVol : INTEGER; {spool file volume reference number} bFileVers : SignedByte; {spool file version number} bJobX: SignedByte {used internal ly } END; TPrStl = RECORD wDev: INTEGER; {high byte specifies device} {more fields for internal use} END; ll/-136 Printing Manager Summary TPrXInfo RECORD iRowBytes: INTEGER; {used internally} iBandV: INTEGER; {used internally} iBand.H: INTEGER; {used internally} iDevBytes: I NTEGER; {size of buffer} {more fields for internal use} END; TPRect = "Rect; TPrStatus = RECORD iTotPages: INTEGER; {number of pages i n spool file} iCurPage: INTEGER; {page being printed} iTotCopies: INTEGER; {number of copies requested} iCurCopy: INTEGER; {copy being printed} iTotBands : INTEGER; {used internally} iCurBand : INTEGER; {used internally} fPgDirty: BOOLEAN; {TRUE if started printing page} fimaging: BOOLEAN; {used internally} hPrint: THPrint; (print record} pPrPort: TPPrPort; (printing grafPort} hPic: PicHandle (used internally} END; Routines [Not in ROM] Initi alization and Termi nation PROCEDURE PrOpen; PROCEDURE PrClose; Pri nt Reco rds and Dialogs PROCEDURE PrintDefault (hPrint: THPrint); FUNCTION PrValidate (hPrint : THPrint) BOOLEAN ; FUNCTION PrStlDial og (hPrint: THPrint) : BOOLEAN; FUNCTION PrJobDial og (hPrint: THPrint) : BOOLEAN ; PROCEDURE PrJobMerge (hPrintSrc , hPrintDst: THPrint); Pri nting FUNCTION PrOpenDoc (hPrint: THPrint; pPrPort: TPPrPort; pIOBuf: Ptr) TPPrPort; PROCEDURE PrOpenPage (pPrPort: TPPrPort; pPageFrame: TPRect); PROCEDURE PrClosePage (pPrPort: TPPrPort); PROCEDURE PrCloseDoc (pPrPort : TPPrPort); PROCEDURE PrPicFile (hPrint: THPrint; pPrPort: TPPrPort; pIOBuf: Ptr; pDevBuf : Ptr ; VAR prStatus: TPrStatus) ; Printing Manager III-137 Inside Macintosh Error Handling FUNCTION PrError INTEGER; PROCEDURE PrSetError (iErr: INTEGER); Low-Level Driver Access PROCEDURE PrDrvrOpen; PROCEDURE PrDrvrClose ; PROCEDURE PrCtlCall (iWhichCtl : INTEGER; 1Paraml,1Param2 ,1Param3 : LONGINT); FUNCTION PrDrvrDCE Handle; FUNCTION PrDrvrVers : INTEGER; Assembly-Language Information Constants ; Printing methods bDraftLoop .EQU 0 ;draft printing bSpoolLoop . EQU 1 ;spool printing ; Result codes no Err .EQU 0 ;no error iPrSavPFil .EQU -1 ;saving spool file controlErr .EQU -17 ;unimplemented control instruction iIOAbort . EQU -27 ;I/O abort error iMernFullErr . EQU -108 ;not enough room in heap zone iPrAbort .EQU 128 ;application or user requested abort ; Printer Driver Control call parameters iPrDevCtl .EQU 7 ;printer control lPrReset .EQU 1 ; reset printer iPrLineFeed .EQU 3 ; carriage return/paper advance iPrLFSixth .EQU 3 ;standard 1/6-inch line feed lPrPageEnd .EQU 2 ; end page iPrBitsCtl .EQU 4 ;bit map printing lScreenBits .EQU 0 ; default for printer lPaintBits .EQU 1 ; square dots (72 by 72) iPrIOCtl .EQU 5 ;text streaming ; Printer Driver info rmation iPrDrvrRef .EQU -3 ;Printer Driver reference number III-138 Printing Manager Summary Printing Graf Port Data Structure gPort GrafPort to draw in (portRec bytes) iPrPortSize Size in bytes of printing grafPort Print Record Data Structure iPrVersion Printing Manager version (word) prlnfo Printer information subrecord ( 14 bytes) rPaper Paper rectangle (8 bytes) prStl Additional device information (8 bytes) prXInfo Additional device information (16 bytes) prJob Job subrecord (iPrJobSize bytes) iPrintSize Size in bytes of print record Structure of Printer Information Subrecord iVRes Vertical resolution of printer (word) iHRes Horizontal resolution of printer (word) rPage Page rectangle (8 bytes) Structure of Job Subrecord iFstPage First page to print (word) iLstPage Last page to print (word) iCopies Number of copies (word) bJDocLoop Printing method (byte) pldleProc Address of background procedure pFileName Pointer to spool file name (preceded by length byte) iFileVol Spool file volume reference number (word) bFileVers Spool file version number (byte) iPrJobSize Size in bytes of job subrecord Structure of PrXlnfo Subrecord iDevBytes Size of buffer (word) Structure of Printer Status Record iTotPages Number of pages in spool file (word) iCurPage Page being printed (word) iTotCopies Number of copies requested (word) iCurCopy Copy being printed (word) fPgDirty Nonzero if started printing page (byte) hPrint Handle to print record pPrPort Pointer to printing grafPort iPrStatSize Size in bytes of printer status record Printing Manager IJJ-139 Inside Macintosh Variables PrintErr Result code from last Printing Manager routine (word) ///-140 Printing Manager Summary QUICKDRAW Constants CONST { Source transfer modes srcCopy 0; srcOr l; srcXor 2; srcBic 3; notSrcCopy 4; notSrcOr 5; notSrcXor 6; notSrcBic 7; { Pattern transfer modes patCopy 8; patOr 9; patXor 10; patBic 11; notPatCopy 12; notPatOr 13; notPatXor 14 ; notPatBic 15; { Standard colors for ForeColor and BackColor } blackColor 33; whiteColor 30; redColor 205; greenColor 341 ; blueColor 409; cyanColor 273; magentaColor 137; yellowColor 69; { Standard picture comments picLParen O; picRParen 1; Data Types TYPE Styleitem (bold,italic , underline,outline,shadow , condense,extend); Style SET OF Styleitem; QuickDraw IIl-141 Inside Macintosh VHSelect = (v, h) ; Point RECORD CASE INTEGER OF O: (v: INTEGER; {vertical coordinate} h: INTEGER); {horizontal coordinate } 1: (vh: ARRAY[VHSelect] OF INTEGER) END; Rect RECORD CASE INTEGER OF 0: (top: INTEGER; left: INTEGER; bottom : INTEGER; right: INTEGER); 1: (topLeft: Point; botRight: Point) END; RgnHandle "RgnPtr; RgnPtr "Region; Region RECORD rgnSize: INTEGER; {size in bytes} rgnBBox: Rect; {enclosing rectangle} {more data if not rectangular} END; BitMap RECORD baseAddr: Ptr; {pointer to bit image} rowBytes: INTEGER; {row width} bounds : Rect {boundary rectangle} END; Pattern= PACKED ARRAY[0 .. 7] OF 0 .. 255; Bits16 ARRAY[0 . . 15) OF INTEGER; Cursor RECORD data: Bitsl6; {cursor image} mask: Bits16; {cursor mask} hotspot: Point {point aligned with mouse } END; 111-142 Quick.Draw Summary QDProcsPtr "QDProcs; QDProcs RECORD textProc: Ptr; {text drawing} lineProc: Ptr; {line drawing} rectProc: Ptr; {rectangle drawing} rRectProc: Ptr; {roundRect drawing} ovalProc: Ptr; {oval drawing} arcProc: Ptr; {arc/wedge drawing} rgnProc: Ptr; {region drawing} bitsProc: Ptr; {bit transfer} commentProc: Ptr; {picture comment processing} txMeasProc: Ptr; {text width meas urement} getPicProc: Ptr; {pi cture retrieva l} putPicProc : Ptr {picture saving} END; GrafPtr "GrafPort; GrafPort RECORD device : INTEGER; {device- specific information} portBits: BitMap; {grafPort's bit map} portRect: Rect; {grafPort ' s rectangle} visRgn: RgnHandle; {visible region} clipRgn: RgnHandle; {clipping region} bkPat: Pattern; {background pattern} fillPat: Pattern; {fill patte rn} pnLoc: Point; {pen location} pnSize: Point; {pen s ize} pnMode: INTEGER; {pen's transfer mode} pnPat: Patt ern; {pen pattern} pnVis: INTEGER; {pen visibility } txFont: INTEGER; {font number for text} txFace: Style; {text 's character styl e } txMode: INTEGER; {text ' s transfer mode} txSize: INTEGER; {font size for text} spExtra: Fixed; {extra space} fgColor: LONGINT ; {foreground color} bkColor : LONGINT; {background color} colrBit: INTEGER; {color bit} patStretch: INTEGER; {used internally } picSave: Handle; {picture being saved} rgnSave: Handle; {region being saved} polySave: Handle; {polygon being saved} graf Procs : QDProcsPt r {low-level drawing routines } END; PicHandle = "P icPtr; PicPtr "Picture; Picture RECORD picSize : INTEGER; {size in bytes} picFrame: Rect; {picture frame} {picture definition data} END; Quick.Draw 111-143 Inside Macintosh PolyHandle = "PolyPtr; PolyPtr = "Polygon; Polygon =RECORD polySize: INTEGER; {size in bytes } polyBBox: Rect; {enclosing rectangle} polyPoints: ARRAY[0 .. 0] OF Point END; PenState =RECORD pnLoc: Point; {pen location} pnSize : Point; {pen size} pnMode: INTEGER; {pen's transfer model pnPat: Pattern {pen pattern} END; Font Info =RECORD ascent: INTEGER; {ascent} descent: INTEGER; {descent} widMax: INTEGER; {maximum character width} leading : INTEGER {leading} END; GrafVerb = (frame,paint,erase,invert, fill); Variables VAR thePort : GrafPtr; {pointer to current grafPort} white: Pattern; {all-white pattern} black : Pattern; {all-black pattern} gray: Pattern; {50% gray pattern} l tGray: Pattern; {25% gray pattern} dkGray: Pattern; {75% gray pattern} arrow: Cursor; {standard arrow cursor} screenBits : BitMap; {the entire screen} randSeed: LONGINT; {determines where Random sequence begins} Routines Graf Port Routines PROCEDURE InitGraf (globalPtr: Ptr); PROCEDURE OpenPort (port: GrafPtr) ; PROCEDURE InitPort (port: GrafPtr) ; PROCEDURE ClosePort (port: GrafPtr) ; PROCEDURE SetPort (port: GrafPtr) ; PROCEDURE GetPort (VAR port : GrafPtr); PROCEDURE GrafDevi ce (device : INTEGER); PROCEDURE SetPortBits (bm: BitMap) ; PROCEDURE PortSize (width,height: I NTEGER); JJ/-144 QuickDraw Summary PROCEDURE MovePortTo (leftGlobal,topGlobal: INTEGER); PROCEDURE SetOrigin (h , v : INTEGER); PROCEDURE Set Clip (rgn: RgnHandle) ; PROCEDURE Get Clip (rgn: RgnHandl e); PROCEDURE ClipRect (r: Rect); PROCEDURE BackPat (pat : Pattern); Cursor Handling PROCEDURE InitCursor; PROCEDURE SetCursor (crsr: Cursor ) ; PROCEDURE HideCursor; PROCEDURE ShowCursor; PROCEDURE ObscureCursor; Pen and Line Drawing PROCEDURE HidePen; PROCEDURE ShowPen; PROCEDURE GetPen (VAR pt: Point); PROCEDURE GetPenState (VAR pnState : PenState) ; PROCEDURE SetPenState (pnState: PenState); PROCEDURE PenSize (width, height : INTEGER); PROCEDURE PenMode (mode : INTEGER); PROCEDURE PenPat (pat: Pattern); PROCEDURE PenNorrnal; PROCEDURE MoveTo (h, v: INTEGER) ; PROCEDURE Move (dh,dv: INTEGER); PROCEDURE LineTo (h, v : INTEGER); PROCEDURE Li ne (dh, dv: INTEGER); Text Drawing PROCEDURE TextFont (font : INTEGER) ; PROCEDURE Text Face (f ace: Style); PROCEDURE TextMode (mode: I NTEGER); PROCEDURE Text Size (size: INTEGER); PROCEDURE SpaceExtra (extra: Fixed); PROCEDURE DrawChar (ch: CHAR); PROCEDURE Drawstring (s: Str255); PROCEDURE DrawText (textBuf: Ptr; firstByte,byteCount: INTEGER); FUNCTION CharWidth (ch: CHAR) : INTEGER; FUNCTION StringWidth (s: Str255) : I NTEGER; FUNCTION TextWidth (textBuf: Ptr; firstByte,byteCount : I NTEGER) INTEGER; PROCEDURE GetFontinfo (VAR info: Font i nfo); Quick.Draw III-145 Inside Macintosh Drawing in Color PROCEDURE ForeColor (color: LONGINT); PROCEDURE BackColor (color: LONGINT); PROCEDURE ColorBi t (whichBit: INTEGER); Calculations with Rectangles PROCEDURE SetRect (VAR r : Rect; left, t op, right , bottom: INTEGER); PROCEDURE OffsetRect (VAR r : Rect; dh,dv: INTEGER); PROCEDURE InsetRect (VAR r : Rect; dh, dv: INTEGER); FUNCTION SectRect (srcl , src2: Rect; VAR dstRect : Rect) : BOOLEAN; PROCEDURE UnionRect (srcl , src2 : Rect; VAR dstRect : Rect); FUNCTION PtinRect (pt: Point; r: Rect) : BOOLEAN; PROCEDURE Pt2Rect (ptl , pt2 : Point; VAR dstRect: Rect); PROCEDURE PtToAngle (r: Rect; pt : Point; VAR angle: INTEGER); FUNCTION EqualRect (rectl,rect2: Rect) : BOOLEAN ; FUNCTION ErnptyRect (r: Rect) : BOOLEAN ; Graphic Operations on Rectangles PROCEDURE FrameRect (r : Rect); PROCEDURE PaintRect (r: Rect ); PROCEDURE EraseRect (r: Rect ); PROCEDURE InvertRect (r: Rect) ; PROCEDURE FillRect (r: Rect; pat: Pattern); Graphic Operations on Ovals PROCEDURE FrameOval (r: Rect); PROCEDURE PaintOval (r: Rect); PROCEDURE EraseOval (r: Rect); PROCEDURE InvertOval (r: Rect ); PROCEDURE FillOval (r: Rect; pat: Pattern); Graphic Operations on Rounded-Corner Rectangles PROCEDURE FrameRoundRect (r: Rect ; ovalWidth , ovalHeight: INTEGER); PROCEDURE PaintRoundRect (r: Rect; ovalWidth, ovalHeight : INTEGER); PROCEDURE EraseRoundRect (r: Rect; ovalWidth, ovalHeight: INTEGER) ; PROCEDURE InvertRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER); PROCEDURE FillRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER; pat: Pattern); 1//-146 QuickDraw Summary Graph ic Operations on Arcs and Wedges PROCEDURE FrameArc (r: Rect; startAngle,arcAngle : INTEGER); PROCEDURE PaintArc (r: Rect; startAngle , arcAngle: INTEGER); PROCEDURE EraseArc (r : Rect; startAngle , arcAngle : INTEGER); PROCEDURE InvertArc (r: Rect; startAngl e , arcAngle : INTEGER); PROCEDURE FillArc (r: Rect; startAngle , arcAngle: INTEGER; pat : Pattern); Calculations with Regions FUNCTION NewRgn : RgnHandle; PROCEDURE OpenRgn; PROCEDURE CloseRgn (dstRgn : RgnHandle); PROCEDURE DisposeRgn (rgn: RgnHandle ); PROCEDURE CopyRgn (srcRgn, dstRgn: RgnHandl e ) ; PROCEDURE SetEmptyRgn (rgn: RgnHandle); PROCEDURE SetRectRgn (rgn : RgnHandle; left , top,right,bottom: INTEGER); PROCEDURE RectRgn (rgn: RgnHandl e; r: Rect); PROCEDURE OffsetRgn (rgn: RgnHandle; dh,dv: INTEGER) ; PROCEDURE InsetRgn (rgn : RgnHandle ; dh , dv : INTEGER); PROCEDURE SectRgn (srcRgnA, srcRgnB, dstRgn: RgnHandle) ; PROCEDURE UnionRgn (srcRgnA, s r cRgnB, dstRgn : RgnHandle); PROCEDURE Dif fRgn (srcRgnA, srcRgnB, dstRgn : RgnHandle); PROCEDURE XorRgn (srcRgnA, srcRgnB , dstRgn : RgnHandle); FUNCTION PtinRgn (pt : Point; rgn: RgnHandle) : BOOLEAN; FUNCTION RectinRgn (r: Rect; rgn : RgnHandle) : BOOLEAN; FUNCTION EqualRgn (rgnA, rgnB : RgnHandle) : BOOLEAN; FUNCTION EmptyRgn (rgn : RgnHandle) : BOOLEAN; Graphic Operations on Regions PROCEDURE FrameRgn (rgn: RgnHandle) ; PROCEDURE PaintRgn (rgn: RgnHandle) ; PROCEDURE EraseRgn (rgn: RgnHandle) ; PROCEDURE InvertRgn (rgn: RgnHandle) ; PROCEDURE FillRgn (rgn: RgnHandle; pat : Pattern); Bit Transfer Operations PROCEDURE ScrollRect (r: Rect; dh , d v : INTEGER; updateRgn: RgnHandle); PROCEDURE CopyBits (srcBits , dstBits : BitMap; srcRect , dstRect: Rect ; mode : INTEGER; maskRgn: RgnHandle); QuickDraw 111-147 Inside Macintosh Pictures FUNCTION OpenPicture (picFrame: Rect) : PicHandle; PROCEDURE PicComment (kind, dataSize: INTEGER; dataHandle: Handle); PROCEDURE ClosePicture; PROCEDURE DrawPicture (myPicture: PicHandle; dstRect: Rect); PROCEDURE KillPicture (myPicture: PicHandle); Calculations with Polygons FUNCTION OpenPoly : PolyHandle; PROCEDURE ClosePoly; PROCEDURE KillPoly (poly: PolyHandle); PROCEDURE OffsetPoly (poly: PolyHandle; dh, dv: INTEGER); Graphic Operations on Polygons PROCEDURE FramePoly (poly: PolyHandle); PROCEDURE PaintPoly (poly: PolyHandle); PROCEDURE ErasePoly (poly: PolyHandle); PROCEDURE InvertPoly (poly: PolyHandle); PROCEDURE FillPoly (poly : PolyHandle; pat: Pattern); Calculations with Points PROCEDURE AddPt (srcPt: Point; VAR dstPt: Point); PROCEDURE SubPt (srcPt: Point; VAR dstPt: Point); PROCEDURE SetPt (VAR pt: Point; h, v : INTEGER) ; FUNCTION EqualPt (ptl,pt2: Point) : BOOLEAN; PROCEDURE LocalToGlobal (VAR pt : Point) ; PROCEDURE GlobalToLocal (VAR pt: Point); Miscellaneous Routines FUNCTION Random : INTEGER; FUNCTION GetPixel (h,v: INTEGER) : BOOLEAN; PROCEDURE StuffHex (thingPtr: Ptr; s: Str255); PROCEDURE ScalePt (VAR pt: Point; srcRect,dstRect: Rect); PROCEDURE MapPt (VAR pt: Point; srcRect,dstRect: Rect); PROCEDURE MapRect (VAR r: Rect; srcRect,dstRect: Rect); PROCEDURE MapRgn (rgn: RgnHandle; srcRect,dstRect: Rect); PROCEDURE MapPoly (poly: PolyHandle; srcRect,dstRect: Rect); III-148 QuickDraw Summary Customiz ing QuickDraw Operations PROCEDURE SetStdProcs (VAR procs: QDProcs); PROCEDURE StdText (byteCount: INTEGER; textBuf: Ptr; nurner,denom: Point); PROCEDURE Std.Line (newPt: Point); PROCEDURE StdRect (verb: GrafVerb; r: Rect); PROCEDURE StdRRect (verb : GrafVerb; r: Rect; ovalwidth,oval Height : INTEGER); PROCEDURE StdOval (verb: GrafVerb; r: Rect); PROCEDURE StdArc (verb: GrafVerb ; r : Rect; startAngle,arcAngle: INTEGER); PROCEDURE StdPoly (verb : GrafVerb; poly : PolyHandle ); PROCEDURE StdRgn (verb : Gr afVerb; rgn: RgnHandle ); PROCEDURE StdBits (VAR srcBi ts: BitMap; VAR srcRect ,dstRect: Rect; mode: INTEGER; maskRgn : RgnHandle); PROCEDURE StdComment (kind,dataSize: INTEGER; dataHandle: Handle); FUNCTION StdTxMeas (byteCount: INTEGER; textAddr: Ptr; VAR numer, denom: Point; VAR info: Fontinfo) : INTEGER; PROCEDURE StdGet Pic (dataPtr: Ptr; byteCount : INTEGER); PROCEDURE StdPutPic (dataPt r : Ptr; byteCount: INTEGER); Assembly-Language Information Constants ; Size in bytes of QuickDraw global vari ables grafSi ze .EQU 206 ; Source transfer modes srcCopy .EQU 0 srcOr . EQU 1 srcXor .EQU 2 srcBic .EQU 3 notSrcCopy .EQU 4 notSrcOr .EQU 5 notSrcXor .EQU 6 notSrcBic .EQU 7 ; Pattern t r ansfer modes patCopy .EQU 8 pa tor .EQU 9 patXor .EQU 10 patBic .EQU 11 notPatCopy . EQU 12 notPatOr .EQU 13 notPatXor .EQU 14 notPatBic .EQU 15 Quick.Draw llI-149 Inside Macintosh ; Standard colors for ForeColor and BackColor blackColor .EQU 33 whiteCo l or .EQU 30 redColor . EQU 205 greenColor .EQU 341 blueColor .EQU 409 cyanColor .EQU 273 magentaColor . EQU 137 yellowCol or .EQU 69 ; Standard picture comments picLParen .EQU 0 picRParen .EQU 1 ; Character style boldBit .EQU 0 italicBit .EQU 1 ulineBit .EQU 2 outlineBit .EQU 3 shadowBit .EQU 4 condenseBit .EQU 5 extendBit .EQU 6 ; Graphic operati ons frame .EQU 0 paint . EQU 1 erase .EQU 2 invert .EQU 3 fill .EQU 4 Point Data Structure v Vertical coordinate (word) h Horizontal coordinate (word) Rectangle Data Structure top Vertical coordinate oftop left comer (word) left Horizontal coordinate of top left comer (word) bottom Vertical coordinate of bottom right comer (word) right Horizontal coordinate of bottom right comer (word) topLeft Top left corner (point; long) botRight Bottom right comer (point; long) III-150 QuickDraw Summary Region Data Structu re rgnSize Size in bytes (word) rgnBBox Enclosing rectangle (8 bytes) rgnData More data if not rectangular Bit Map Data Structu re baseAddr Pointer to bit image row Bytes Row width (word) bounds Boundary rectangle (8 bytes) bitMapRec Size in bytes of bit map data structure Cursor Data Structure data Cursor image (32 bytes) mask Cursor mask (32 bytes) hotSpot Point aligned with mouse (long) cursRec Size in bytes of cursor data structure Structure of QDProcs Record textProc Address of text-drawing routine lineProc Address of line-drawing routine rectProc Address of rectangle-drawing routine rRectProc Address of roundRect-drawing routine ovalProc Address of oval-drawing routine arcProc Address of arc/wedge-drawing routine polyProc Address of polygon-drawing routine rgnProc Address of region-drawing routine bitsProc Address of bit-transfer routine commentProc Address of routine for processing picture comments txMeasProc Address of routine for measuring text width getPicProc Address of picture-retrieval routine putPicProc Address of picture-saving routine qdProcsRec Size in bytes of QDProcs record Graf Port Data Structure device Font-specific information (word) portBits GrafPort's bit map (bitMapRec bytes) portBounds Boundary rectangle of grafPort's bit map (8 bytes) portRect GrafPort's rectangle (8 bytes) visRgn Handle to visible region clipRgn Handle to clipping region bkPat Background pattern (8 bytes) fillPat Fill pattern (8 bytes) pnLoc Pen location (point; long) QuickDraw lll-151 Inside Macintosh pnSize Pen size (point; long) pnMode Pen's transfer mode (word) pnPat Pen pattern (8 bytes) pnVis Pen visibility (word) txFont Font number for text (word) txFace Text's character style (word) txMode Text's transfer mode (word) txSize Font size for text (word) spExtra Extra space (long) fgColor Foreground color (long) bkColor Background color (long) colrBit Color bit (word) picSave Handle to picture being saved rgnSave Handle to region being saved poly Save Handle to polygon being saved grafProcs Pointer to QDProcs record portRec Size in bytes of grafPort Picture Data Structure picSize Size in bytes (word) picFrame Picture frame (rectangle; 8 bytes) picData Picture definition data Polygon Data Structure polySize Size in bytes (word) polyBBox Enclosing rectangle (8 bytes) polyPoints Polygon points Pen State Data Structure psLoc Pen location (point; long) psSize Pen size (point; long) psMode Pen's transfer mode (word) psPat Pen pattern (8 bytes) psRec Size in bytes of pen state data structure Font Information Data Structure ascent Ascent (word) descent Descent (word) widMax Maximum character width (word) leading Leading (word) III-152 QuickDraw Summary Special Macro Names Pascal name Macro name SetPortBits SetPBits InvertRect InverRect InvertRoundRect InverRoundRect DisposeRgn =DisposRgn SetRectRgn _SetRecRgn OffsetRgn _OfSetRgn InvertRgn _InverRgn ClosePoly _ClosePgon Vari ables RndSeed Random number seed (long) Quick.Draw JJJ-153 Inside Macintosh RESOURCE MANAGE R Constants CONST { Masks for resource attributes resSysHeap 64; {set if read into system heap} resPurgeable 32; {set if purgeable } res Locked 16; {set i f locked} resProtected 8; {set i f protected} resPreload 4; {set i f to be preloaded} res Changed 2; {set i f to be written to resource file} { Resource Manager result codes } resNotFound = - 192; {resource not found ) resFNotFound - 193; {resource file not found) addResFailed - 194; {AddResource failed } nnvResFailed -196; {RmveResource failed} { Masks for resource file attributes } mapReadOnl y = 128; {set if file is read-only} mapCompact 64; {set to compact file on update} mapChanged 32; {set to write map on update} Data Types TYPE ResType =PACKED ARRAY[l. .4) OF CHAR; Routines Initial ization FUNCTION InitResources INTEGER; PROCEDURE RsrcZoneinit; Open ing and Closing Resource Files PROCEDURE CreateResFile (fileName: Str255); FUNCTION OpenResFile (fileName: Str255) INTEGER; PROCEDURE CloseResFile (refNum: INTEGER); III-154 Resource Manager Summary Checking for Errors FUNCTION ResError : INTEGER; Setting the Current Resource File FUNCTION CurResFile : INTEGER; FUNCTION HomeResFile (theResource: Handle) INTEGER; PROCEDURE UseResFile (refNum: INTEGER); Getting Resource Types FUNCTION CountTypes : INTEGER; PROCEDURE GetindType (VAR theType: ResType; index: INTEGER); Getting and Disposing of Resources PROCEDURE SetResLoad (load: BOOLEAN); FUNCTION CountResources (theType : Res Type) : INTEGER; FUNCTION Get Ind.Resource (theType: ResType; index: INTEGER) : Handle; FUNCTION GetResource (theType: ResType; theID: INTEGER) : Handle; FUNCTION GetNamed.Resource (theType: ResType; name: Str255) : Handle; PROCEDURE Load.Resource (theResource : Handle); PROCEDURE ReleaseResource (theResource: Handle); PROCEDURE DetachResource (theResource: Handle); Getting Resource Information FUNCTION UniqueID (theType: ResType) : INTEGER; PROCEDURE GetResinfo (theResource: Handle; VA~ theID: INTEGER; VAR theType: ResType; VAR name: Str255); FUNCTION GetResAttrs (theResource: Handle) INTEGER; FUNCTION SizeResource (theResource: Handl e) : LONGINT; Modifying Resources PROCEDURE SetResinfo (theResource: Handle; theID : INTEGER; name: Str255); PROCEDURE SetResAttrs (theResource: Handle; attrs: INTEGER); PROCEDURE Changed.Resource (theResource: Handle); PROCEDURE Add.Resource (theData: Handle; theType: ResType; theID: INTEGER; name: Str255); PROCEDURE RmveResource (theResource: Handle); PROCEDURE UpdateResFile (refNum: INTEGER); PROCEDURE WriteResource (theResource: Handle); PROCEDURE SetResPurge (install: BOOLEAN); Resource Manager JII-155 Inside Macintosh Advanced Rou tines FUNCTION GetResFileAttrs (refNum: INTEGER) : INTEGER; PROCEDURE SetResFileAtt rs (refNum: INTEGER; attrs: I NTEGER); Assembly-Language Information Constants ; Resource attributes resSys Heap . EQU 6 ;set if read into system hea p r esPurgeable .EQU 5 ; set i f purgeable res Locked .EQU 4 ;set i f locked resProtected . EQU 3 ;set if protected resPreload .EQU 2 ;set if to be preloaded r esChanged .EQU 1 ;set if to be written to resource file ; Resource Manager result codes resNotFound . EQU - 192 ;resource not found resFNotFound . EQU - 193 ;resource file not found addResFailed .EQU -194 ;AddResource failed rmvResFailed .EQU -196 ;RmveResource failed ; Resource fi l e attributes mapReadOnly .EQU 7 ;set if fi l e is read- only mapCompact .EQU 6 ;set to compact file on update mapChanged . EQU 5 ;set to write map on updat e Special Macro Names Pascal name Macro name SizeResource SizeRsrc Variables TopMapHndl Handle to resource map of most recently opened resource file SysMapHndl Handle to map of system resource file SysMap Reference number of system resource file (word) CurMap Reference number of current resource file (word) ResLoad Current SetResLoad state (word) ResErr Current value of ResError (word) ResErrProc Address of resource error procedure SysResName Name of system resource file (length byte followed by up to 19 characters) III-156 Resource Manager Summary SCRAP MANAGER Constants CONST { Scrap Manager result codes } noScrapErr -1 00; {desk scrap isn ' t initialized} noTypeErr - 102; {no data of the requested type} Data Types TYPE PScrapStuff "'ScrapStuff; ScrapStuf f RECORD scrapSize: LONGINT; {size of desk scrap} scrapHandle : Handle; {handle to desk scrap} scrapCount: INTEGER; {count changed by ZeroScrap} scrapState : INTEGER; {tells where desk scrap is} scrapName: StringPtr {scrap file name} END; Routines Getting Desk Scrap Information FUNCTION InfoScrap : PScrapStuff; Keeping the Desk Scrap on the Disk FUNCTION UnloadScrap LONGINT; FUNCTION LoadScrap : LONGINT; Writing to the Desk Scrap FUNCTION ZeroScrap : LONGINT; FUNCTION PutScrap (length: LONGINT; theType: ResType; source: Ptr) LONGINT; Reading from the Desk Scrap FUNCTION GetScrap (hDest : Handle; theType: ResType; VAR offset : LONGINT) : LONGINT ; Scrap Manager JJJ-157 Inside Macintosh Assembly-Language Information Constants ; Scrap Manager result codes noScrapErr .EQU -100 ;desk scrap isn't initialized noTypeErr . EQU -102 ;no data of the requested type Special Macro Names Pascal name Macro name LoadScrap _LodeScrap UnloadScrap _ UnlodeScrap Variables ScrapSize Size in bytes of desk scrap (long) ScrapHandle Handle to desk scrap in memory ScrapCount Count changed by ZeroScrap (word) ScrapState Tells where desk scrap is (word) ScrapName Pointer to scrap file name (preceded by length byte) III-158 Scrap Manager Summary SEGMENT LOADER Constants CONST { Message returned by CountAppleFiles appOpen 0; {open the document(s) l appPrint 1; {print the document(s)} Data Types TYPE AppFile = RECORD vRefNum: INTEGER; {volume reference number} fType: OSType; {file type} versNum: INTEGER; {version number} fNarne: Str255 {file name} END; Routines PROCEDURE CountAppFiles (VAR message: INTEGER; VAR count: INTEGER); (Not in ROM] PROCEDURE GetAppFiles (index: INTEGER; VAR theFile: AppFile); [Notin ROM] PROCEDURE ClrAppFil es (index: INTEGER) ; [Not in ROM] PROCEDURE GetAppParms (VAR apName : Str255; VAR apRefNum: INTEGER; VAR apPararn: Handle); PROCEDURE UnloadSeg (routineAddr: Ptr); PROCEDURE ExitToShell; Assembly-Language Information Advanced Routines Trap macro On entry Chain (AO): pointer to application's file name {preceded by length byte) 4(AO): configuration of sound and screen buffers (word) Launch (AO): pointer to application's file name (preceded by length byte) 4(AO): configuration of sound and screen buffers (word) _LoadSeg stack: segment number (word) Segment Loader II!-159 Inside Macintosh Variables AppPannHandle Handle to Finder information CurApName Name of current application (length byte followed by up to 31 characters) CurApRefNum Reference number of current application's resource file (word) CurPageOption Sound/screen buffer configuration passed to Chain or Launch (word) CurJTOffset Offset to jump table from location pointed to by AS (word) FinderName Name of the Finder (length byte followed by up to 15 characters) ///-160 Segment Loader Summary SERIAL DRIVERS Constants CONST { Driver reset information } baud300 380; {300 baud} baud600 189; {600 baud} baud1200 94; {1200 baud} baud1800 62; {1800 baud} baud2400 46; {2400 baud} baud3600 30; {3600 baud} baud4800 22; {4800 baud} baud7200 14; {7200 baud} baud9600 10; {9600 baud} baud19200 4; {19200 baud} baud57600 O; {57600 baud} stoplO 16384; {1 stop bit} stop15 -327 68; {1.5 stop bits} stop20 -16384; {2 stop bits} noParity 0; {no parity} oddParity 4096; {odd parity} evenParity 12288; {even parity} data5 O; {5 data bits} data6 2048; {6 data bits} data7 1024; {7 data bits} data8 3072; {8 data bits} { Masks for errors sWOverrunErr = l; {set i f software overrun error} parityErr 16; {set i f parity error} hWOverrunErr = 32; {set i f hardware overrun error} frarningErr 64; {set i f framing error} { Masks for changes that cause events to be posted } ctsEvent 32; {set if CTS change will cause event to be } { posted} breakEvent 128; {set if break status change will cause event { to be posted} { Indication that an XOff character was sent } xOffWasSent = $80; { Result codes noErr O; {no error} openErr -23; {attempt to open RAM Serial Driver failed} Serial Drivers JJJ-161 Inside Macintosh Data Types TYPE SPortSel (sPortA, {modem port} sPortB {printer port}); SerShk = PACKED RECORD fXOn: Byte; {XOn/XOff output flow control flag} fCTS: Byte; {CTS hardware handshake flag} xOn: CHAR; {XOn character} xOff : CHAR; {XOff character} errs: Byte; {errors that cause abort} evts : Byte; {status changes that cause events} finX: Byte; {XOn/ XOff input flow control flag} null: Byte {not u sed} END; SerStaRec = PACKED RECORD curnErrs : Byte; {cumulative errors} xOffSent: Byte; {XOff sent as input flow control} rdPend: Byte; {read pending flag } wrPend: Byte; {write pending flag} ctsHold: Byte; {CTS flow control hold flag} xOffHol d: Byte {XOff flow control hold flag} END; Routines [Not in ROM] Opening and Closing the RAM Serial Driver FUNCTION RAMSDOpen (whichPort: SPortSel) : OSErr; PROCEDURE RAMSDClose (whichPort: SPortSel); Changing Serial Driver Information FUNCTION SerReset (refNum: INTEGER; serConfig: INTEGER) : OSErr; FUNCTION SerSetBuf (refNum: INTEGER; serBPtr: Ptr; serBLen: INTEGER) OSErr ; FUNCTION SerHShake (refNum: INTEGER; flags : SerShk) : OSErr; FUNCTION SerSetBrk (refNum : INTEGER) OSErr; FUNCTION SerClrBrk (refNum: INTEGER) : OSErr; Getting Serial Driver Information FUNCTI ON SerGetBuf (refNum: INTEGER; VAR count: LONGINT) : OSErr; FUNCTION SerStatus (refNum: INTEGER; VAR serSta: SerStaRec) : OSErr; l//-162 Serial Drivers Summary Advanced Control Calls (RAM Serial Driver) cs Code csParam Effect 13 baudRate Set baud rate (actual rate, as a n integer) 19 char Replace parity errors 21 Unconditionally set XOff for output flow control 22 Unconditionally clear XOff for input flow control 23 Send XOn for input flow control if XOff was sent last 24 Unconditionally send XOn for input flow control 25 Send XOff for input flow control if X On was sent last 26 Unconditionally send XOff fo r input flow control 27 Reset SCC channel Driver Names and Reference Numbers Driver Driver name Reference number Modem port input .Aln -6 Modem port output .AOut -7 Printer port input .Bin -8 Printer port output .BOut -9 Assembly-Language Information Constants ; Re s ul t codes no Err . EQU 0 ; no error openErr . EQU -23 ;att empt t o op e n RAM Seri al Driver fa iled Structure of Control Information for SerHShake shFXOn X On!XOff output flow control flag (byte) shFCTS CTS h ardware handsh ake flag (byte) shXOn XOn character (byte) shXOff XOff character (byte) shErrs Errors that cause abort (byte) shEvts Status changes that cause events (byte) shFinX XOn/XOff input flow control fl ag (byte ) Serial Drivers lll-1 63 Inside Macintosh Structure of Status Information for SerStatus ssCumErrs Cumulative errors (byte) ssXOffSent XOff sent as input flow control (byte) ssRdPend Read pending fl ag (byte) ssWrPend Write pending flag (byte) ssCTSHold CTS flow control hold flag (byte) ssXOftHold XOff flow control hold flag (byte) Equivalent Device Manager Calls Pascal routine Call SerReset Control with csCode=8, csParam=serConfig SerSetBuf Control with csCode=8, csParam=serBPtr, csParam+4=serBLen SerHShake Control with csCode= lO, csParam through csParam+6=fl ags SerSetBrk Control with csCode=12 SerClrBrk Control with csCode=l 1 SerGetBuf Status with csCode=2; count returned in csParam SerStatus Status with csCode=8; serSta returned in csParam through csParam+S ///-164 Serial Drivers Summary SOUND DRIVER Constants CONST { Mode values for synthesizers } swMode -1; {square-wave synthesizer} ftMode 1; {four- tone synthesizer } ffMode O; {free- form synthesizer} Data Types TYPE { Free-form synthesizer } FFSynthPtr "'FFSynthRec; FFSynthRec RECORD mode: INTEGER; {always ffMode} count: Fixed; {"sampling" factor } waveBytes: FreeWave {waveform description} END; FreeWave PACKED ARRAY[0 .. 30000] OF Byte; { Square-wave synthesizer SWSynthPtr = "'SWSynthRec; SWSynthRec = RECORD mode: INTEGER; {always swMode} triplets: Tones {sounds } END; Tones ARRAY [ 0 .. 5000] OF Tone; Tone RECORD count : INTEGER; {frequency} amplitude: INTEGER; {amplitude, 0- 255} duration: INTEGER {duration in ticks} END; Four- tone synthesizer FTSynthPtr "'FTSynthRec; FTSynthRec RECORD mode: INTEGER; {always ftMode} sndRec: FTSndRecPtr {tones to play} END; Sound.Driver JII-165 Inside Macintosh FTSndRecPtr "FTSoundRec; FTSoundRec RECORD duration: INTEGER; {duration in ticks} soundlRate: Fixed; {tone 1 cycle rate} soundlPhase: LONGINT; {tone 1 byte offset} sound2Rate: Fixed; {tone 2 cycle rate} sound2Phase: LONGINT; {tone 2 byte offset} sound3Rate: Fixed; {tone 3 cycle rate } sound3Phase: LONGINT ; {tone 3 byte offset} sound4Rate: Fixed; {tone 4 cycle rate} sound4Phase: LONGINT; {tone 4 byte offset} soundlWave: WavePtr; {tone 1 waveform} sound2Wave: WavePtr; {tone 2 wavefo rm } sound3Wave: WavePtr; {tone 3 waveform} sound4Wave: WavePtr {tone 4 waveform} END; WavePtr = "Wave; Wave =PACKED ARRAY[0 . . 255) OF Byte; Routines [Not in ROM] PROCEDURE StartSound (synthRec: Ptr; nurnBytes: LONGINT; completionRtn : ProcPtr); PROCEDURE StopSound; FUNCTION SoundDone : BOOLEAN; PROCEDURE GetSoundVol (VAR level: INTEGER); PROCEDURE SetSoundVol (level: INTEGER); Assembly-Language Information Routines Pascal name Equivalent for assembly language StartSound Call Write with ioRefNum=-4, ioBuffer=synthRec, ioReqCount=numBytes StopSound Call KillIO and (for square-wave) set CurPitch to 0 SoundDone Poll ioResult field of most recent Write call's parameter block GetSoundVol Get low-order three bits of variable SdVolume SetSoundVol Call this Pascal procedure from your program Variables SdVolume Speaker volume (byte: low-order three bits only) SoundPtr Pointer to four-tone record SoundLevel Amplitude in 740-byte buffer (byte) CurPitch Value of count in square-wave synthesizer buffer (word) III-166 Sound Driver Summary Sound Driver Values for Notes The following table contains values for the rate field of a four-tone synthesizer and the count field of a square-wave synthesizer. A just-tempered scale-in the key of C, as an example- is given in the first four columns; you can use a just-tempered scale for perfect tuning in a particular key. The last four columns give an equal-tempered scale, for applications that may use any key ; this scale is appropriate for most Macintosh sound applications. Following this table is a list of the ratios used in calculating these values, and instructions on how to calculate them for a just- tempered scale in any key. Just-Tempered Scale Equal-Tempered Scale Rate for Count for Rate for Count for Four-Tone Square-Wave Four-Tone Square-Wave Note Long Fixed Word Integer Long Fixed Word Integer 3 octaves below middle C c 612B 0.37956 5CBA 23738 604C 0.37616 5092 23954 C# 667C 0.40033 57EB 22507 6606 0.39853 5851 22609 Db 67A6 0.40488 56EF 22255 D 6051 0.42702 5260 21101 6C17 0.42223 535C 21340 Ebb 6E8F 0.43187 5180 20864 D# 71DF 0.44481 4F21 20257 7284 0.44733 4EAF 20143 Eb 749A 0.45547 4046 19782 E 7976 0.47446 4A2F 18991 7953 0.47392 4A44 19012 F 818F 0.50609 458C 17804 808A 0.50211 4619 17945 F# 88A5 0.53377 41FO 16880 882F 0.53197 422A 16938 Gb 8A32 0.53983 4133 16691 G 91Cl 0.56935 3DD1 15825 9048 0 .56360 3E73 15987 G# 9704 0.59308 3B58 15192 98DC 0.59711 3AF2 15090 Ab 9B79 0.60732 39F4 14836 A A1F3 0.63261 37A3 14243 A1F3 0.63261 37A3 14243 Bbb A3CA 0.63980 3703 14083 A# AAOC 0.66425 34FD 13565 AB94 0.67023 3484 13444 Bb ACBF 0.67479 3429 13353 B B631 0.71169 3174 12660 B5C8 0.71008 3191 12689 2 octaves below middle C c C257 0.75914 2E5D 11869 C097 0.75230 2EC9 11977 C# CCF8 0.80066 2BF6 11254 CCOB 0.79704 2C29 11305 Db CF4C 0.80975 2B77 11127 D DAA2 0.85403 2936 10550 D82D 0.84444 29AE 10670 Ebb DDlD 0.86372 28CO 10432 D# E3BE 0.88962 2790 10128 E508 0.89465 2757 10071 Eb E935 0.91096 26A3 9891 E F2ED 0.94893 2517 9495 F2A6 0.94785 2522 9506 F 1031E 1.01218 22C6 8902 10114 1.00421 230C 8972 F# 1114A 1.06754 20F8 8440 11050 1.06392 2115 8469 Gb 11465 1.07967 2099 8345 G 12382 1.13870 1EE9 7913 12090 1.12720 1F3A 7994 Sound Driver Il/-167 Inside Macintosh Note Long Fixed Word Integer Long Fixed Word Integer 2 octaves below middle C G# 12FA8 1.18616 lDAC 7596 131B8 1.19421 1079 7545 Ab 136Fl 1.21461 lCFA 7418 A 143E6 1.26523 lBDl 7121 143E6 1.26523 lBDl 7121 Bbb 14794 1.27960 1B81 7041 A# 15418 1.32849 1A7E 6782 15729 1.34047 1A42 6722 Bb 1597E 1.34958 1Al4 6676 B 16C63 1.42339 18BA 6330 16B90 1.42017 18C8 6344 1 octave below middle C c 184AE 1.51828 172F 5935 1812F 1.50462 1764 5988 C# 199EF 1.60130 15FB 5627 19816 1.59409 1614 5652 Db 19E97 1.61949 15BC 5564 D 1B543 1.70805 149B 5275 1B05A 1.68887 1407 5335 Ebb 1BA3B 1.72746 1460 5216 D# 1C77B 1.77922 13C8 5064 lCAlO 1.78931 13AC 5036 Eb 1D26A 1.82193 1351 4945 E 1E5D9 1.89784 128C 4748 1E54D 1.89571 1291 4753 F 20630 2.02437 1163 4451 20228 2.00842 1186 4486 F# 22294 2.13507 107C 4220 220BB 2.12785 108A 4234 Gb 228C9 2.15932 1040 4173 G 24704 2.27740 F74 3956 2411F 2.25438 F9D 3997 G# 25F4F 2.37230 ED6 3798 26370 2.38843 EBC 3772 Ab 26DE3 2.42924 E7D 3709 A 287CC 2.53046 DE9 3561 287CC 2.53046 DE9 3561 Bbb 28F28 2.55920 DCl 3521 A# 2A830 2.65698 D3F 3391 2AE51 2.68092 021 3361 Bb 2B2FC 2.69916 DOA 3338 B 2D8C6 2.84677 C5D 3165 20721 2.84035 C64 3172 Middle C c 3095B 3.03654 B97 2967 3025D 3.00923 BB2 2994 C# 333DE 3.20261 AFD 2813 3302C 3.18817 BOA 2826 Db 33D2E 3.23898 ADE 2782 D 36A87 3.41612 A4E 2638 360B5 3.37776 A6C 2668 Ebb 37476 3.45493 A30 2608 D# 38EF7 3.55846 9E4 2532 39420 3.57861 906 2518 Eb 3A4D4 3.64386 9A9 2473 E 3CBB2 3.79568 946 2374 3CA99 3.79140 949 2377 F 40C7A 4.04874 8Bl 2225 40450 4.01685 8C3 2243 F# 44528 4.27014 83E 2110 44176 4.25571 845 2117 Gb 45193 4.31865 826 2086 G 48E09 4.55482 7BA 1978 4823E 4.50876 7CE 1998 G# 4BE9F 4.74461 76B 1899 4C6El 4.77687 75E 1886 Ab 4DBC5 4.85847 73F 1855 A 50F98 5.06091 6F4 1780 50F98 5.06091 6F4 1780 III-168 SoundDriver Summary Note Long Fixed Word Integer Long Fixed Word Integer Middle C Bbb 51E4F 5.11839 6EO 1760 A# 55060 5.31396 6AO 1696 55CA2 5.36185 690 1680 Bb 565F8 5.39832 685 1669 B 5B18B 5.69353 62F 1583 5AE41 5.68068 632 1586 1 octave above middle C c 612B7 6.07310 sec 1484 604BB 6.01848 5D9 1497 C# 667BD 6.40523 57F 1407 66059 6.37636 585 1413 Db 67A5C 6.47797 56F 1391 D 6D50D 6.83223 527 1319 6C169 6.75551 536 1334 Ebb 6E8EB 6.90984 518 1304 D# 71DEE 7.11691 4F2 1266 7283F 7.15721 4EB 1259 Eb 749A8 7.28772 4D4 1236 E 79764 7.59137 4A3 1187 79533 7.58281 4A4 1188 F 818F3 8.09746 459 1113 808Al 8.03371 462 1122. F# 88A51 8.54030 41F 1055 882EC 8.51141 423 1059 Gb 8A326 8.63730 413 1043 G 91C12 9.10965 3DD 989 9047D 9.01753 3E7 999 G# 97D3D 9.48921 3B6 950 98DC2 9.55374 3AF 943 Ab 9B78B 9.71696 39F 927 A AlF30 10.12183 37A 890 A1F30 10.12183 37A 890 Bbb A3C9F 10.23680 370 880 A# AAOBF 10.62791 350 848 AB945 10.72371 348 840 Bb ACBEF 10.79662 343 835 B B6316 11.38705 317 791 B5C83 11.36137 319 793 2 octaves above middle C c C256D 12.14619 2E6 742 C0976 12.03696 2ED 749 C# CCF79 12.81044 2BF 703 CCOBl 12.75270 2C3 707 Db CF4B9 12.95595 2B7 695 D DAAlB 13.66447 293 659 D82D2 13.51102 29B 667 Ebb DD1D6 13.81967 28C 652 D# E3BDC 14.23383 279 633 E507E 14.31442 275 629 Eb E9350 14.57544 26A 618 E F2EC8 15.18274 251 593 F2A65 15.16560 252 594 F 1031E7 16.19493 22C 556 101141 16.06740 231 561 F# 1114Al 17.08058 210 528 1105D8 17.02283 211 529 Gb 11464C 17.27460 20A 522 G 123824 18.21930 lEF 495 1208F9 18.03505 LF4 500 G# 12FA7B 18.97844 IDB 475 131B83 19.10747 1D8 472 Ab 136F15 19.43391 lDO 464 A 143E61 20.24367 lBD 445 143E61 20.24367 lBD 445 Bbb 147930 20.47359 1B8 440 A# 15417F 21.25584 1A8 424 15728A 21.44742 1A4 420 Bb 15970E 21.59323 lAl 417 B 16C620 22.77412 18C 396 16B906 22.72275 180 397 Sound Driver III-169 Inside Macintosh Note Long Fixed Word Integer Long Fixed Word Integer 3 octaves above middle C C 184ADA 24.29239 173 371 1812EB 24.07390 176 374 C# 199EF2 25.62088 160 352 198163 25 .50542 161 353 Db 19E971 25.91188 15C 348 D 1B5436 27.32895 14A 330 1B05A5 27 .02205 14D 333 Ebb 1BA3AC 27 .63934 146 326 D# 1C77B8 28.46765 13D 317 lCAOFD 28.62886 13B 315 Eb 1D26AO 29.15088 135 309 E 1E5D91 30.36549 129 297 1E54CB 30.33122 129 297 F 2063CE 32.38986 116 278 202283 32.13481 118 280 F# 222943 34.16118 108 264 220BAF 34.04564 109 265 Gb 228C97 34.54918 105 261 G 247047 36.43858 F7 247 2411F2 36.07010 FA 250 G# 25F4F5 37.95686 ED 237 263706 38.21494 EC 236 Ab 26DE2A 38.86783 E8 232 A 287CC1 40.48732 DF 223 287CC1 40.48732 DF 223 Bbb 28F27A 40.94717 DC 220 A# 2A82FE 42.51169 D4 212 2AE513 42.89482 D2 210 Bb 2B2FBD 43.18648 DI 209 B 2D8C59 45.54823 C6 198 2D720B 45.44548 C6 198 The following table gives the ratios used in calculating the above values. It shows the relationship between the notes making up the just-tempered scale in the key of C; should you need to implement a just-tempered scale in some other key, you can do so as follows: First get the value of the root note in the proper octave in the equal-tempered scale (from the above table). Then use the following table to determine the values of the intervals for the other notes in the key by multiplying the ratio by the root note. Chromatic Just-tempered Equal-tempered interval Note frequency ratio frequency ratio Interval type 0 c 1.00000 1.00000 Unison 1 C# 1.05469 1.05946' Minor second as chromatic semitone Db 1.06667 Minor second as diatonic semitone 2 D 1.11111 1.12246 Major second as minor tone D 1.12500 Major second as major tone Ebb 1.13778 Diminished third 3 D# 1.17188 1.18921 Augmented second Eb 1.20000 Minor third 4 E 1.25000 1.25992 Major third 5 F 1.33333 1.33484 Fourth 6 F# 1.40625 1.41421 Tritone as augmented fourth Gb 1.42222 Tritone as diminished fifth 7 G 1.50000 1.49831 Fifth III-170 Sowui Driver Summary Chromatic Just-tempered Equal-tempered interval Note frequency ratio frequency ratio Interval type 8 G# 1.56250 1.58740 Augmented fifth Ab 1.60000 Minor sixth 9 A 1.66667 1.68 179 Major sixth Bbb 1.68560 Diminished seventh 10 A# 1.75000 1.78 180 Augmented sixth Bb 1.77778 Minor seventh 11 B 1.87500 1. 88775 Major seventh 12 c 2 .00000 2.00000 Octave Sound Driver ll!-171 Inside Macintosh STANDARD FILE PACKAGE Constants CONST { SFPutFile dialog template · Io ) putDlgID = - 3999; { Item numbers of enabled items in SFPutFile d i alog ) put Save = l; {Save button) putCancel = 2; {Cancel button) putEject = 5; {Eject button) putDrive = 6; {Drive button) put Name = 7; {editText item for file name ) { SFGetFile dialog template ID ) getDlgID = - 4000; { Item numbers of enabled items i n SFGetFile d ialog ) get Open = l; {Open button) get Cancel = 3; {Cancel butt on) getEject = 5; {Eject button) getDrive = 6; {Drive button) getNmList = 7; {useritem for file name list) get Scroll = 8; {useritem for scroll bar) Data Types TYPE SFReply = RECORD good: BOOLEAN; {FALSE if ignore corranand) copy : BOOLEAN; {not used) fType: OSType; {file type or not used ) vRefNum: INTEGER; {volume reference number) version: INTEGER; {file's version number) fName: STRING[63] {file name) END ; SFTypeList = ARRAY[0 .. 3] OF OSType ; 111-172 Standard File Package Summary Routines PROCEDURE SFPutFile (where: Point; prompt: Str255; origName : Str255; dlgHook: ProcPtr; VAR reply : SFReply); PROCEDURE SFPPutFile (where : Point; prompt: Str255; origName : Str255; dlgHook: ProcPtr; VAR reply: SFReply; d l gID : INTEGER; filterProc: ProcPtr); PROCEDURE SFGetFile (where: Point; prompt: Str255; fileFilter : ProcPtr ; numTypes : INTEGER; typeList : SFTypeList ; d l gHook : ProcPtr; VAR reply : SFReply); PROCEDURE SFPGetFile (where: Point; prompt: Str255; fileFilter : ProcPtr ; numTypes: INTEGER; typeList: SFTypeList; dlgHook : ProcPtr; VAR reply: SFReply; dlgID : INTEGER; filterProc: ProcPtr); DlgHook Function FUNCTION MyDlg (item: INTEGER; theDialog: DialogPtr) I NTEGER; FileFilter Function FUNCTION MyFileFilter (paramBlock: ParmBlkPtr) BOOLEAN; Standard SFPutFile Items Item number Item Standard display rectangle Save button (12,74)(82,92) 2 Cancel button (114,74)(184,92) 3 Prompt string (statText) ( 12, 12)( 184,28) 4 Userltem for disk name (209, 16)(295,34) 5 Eject button (21 7 ,43 )(287 ,6 1) 6 Drive button (217,74)(287,92) 7 EditText item for file name ( 14,34)(182,50) 8 Userltem for dotted line (200, 16)(201,88) Standard File Package llI-173 Inside Macintosh Resource IDs of SFPutFile Alerts Alert Resource ID Disk not found -3994 System error -3995 Existing file -3996 Locked disk -3997 Standard SFGetFile Items Item number Item Standard display rectangle 1 Open button ( 152,28)(232,46) 2 Invisible button (1152,59)(1232,77) 3 Cancel button ( 152,90)(232, 108) 4 U serltem for disk name (248,28)(344,46) 5 Eject button (256,59)(336,77) 6 Drive button (256,90)(336, 108) 7 Userltem for file name list ( 12, 11)(125' 125) 8 Userltem for scroll bar (124,11)(140,125) 9 Userltem for dotted line (244,20)(245,116) 10 Invisible text (statText) (1044,20)(1145 ,116) Assembly-Language Information Constants ; SFPutFile dialog template ID putDlgID .EQU -3999 ; Item numbers of enabled items in SFPutFile dialog put Save .EQU 1 ;Save button put Cancel . EQU 2 ;Cancel button putEject .EQU 5 ;Eject button putDrive .EQU 6 ;Drive button put Name .EQU 7 ;edit Text item for file name ; SFGetFile dialog template ID getDlgID .EQU -4000 III-174 Standard File Package Summary ; I tem number s of enabled items in SFGetFile dialog getOpen .EQU 1 ;Open button get Cancel .EQU 3 ;Cancel button getEject . EQU 5 ;Eject button getDrive .EQU 6 ;Drive button getNmList . EQU 7 ;useritem fo r file name list get Scroll .EQU 8 ;useritem for scroll bar ; Routine selectors sfPutFile .EQU 1 sfGetFile .EQU 2 sf PPutFile .EQU 3 sf PGetFile .EQU 4 Reply Record Data Structure rGood 0 if ignore command (byte) trype File type (long) rVolume Volume reference number (word) rVersion File's version number (word) rName File name (length byte followed by up to 63 characters) Trap Macro Name Pack3 Variables SFSaveDisk Negative of volume reference number used by Standard File Package (word) Standard File Package Ill-175 Inside Macintosh SYSTEM ERROR HANDLER Routines PROCEDURE SysError (errorCode: INTEGER); User Alerts ID Explanation 1 Bus error: Invalid memory reference; happens only on a Macintosh XL 2 Address error: Word or long-word reference made to an odd address 3 Illegal instruction: The MC68000 received an instruction it didn't recognize. 4 :zero divide: Signed Divide (DIVS) or Unsigned Divide (DIVU) instruction with a divisor of 0 was executed. 5 Check exception: Check Register Against Bounds (CHK) instruction was executed and failed. Pascal "value out of range" errors are usually reported in this way. 6 TrapV exception: Trap On Overflow (TRAPV) instruction was executed and failed. 7 Privilege violation: Macintosh always runs in supervisor mode; perhaps an erroneous Return From Execution (RTE) instruction was executed. 8 Trace exception: The trace bit in the status register is set. 9 Line 1010 exception: The 1010 trap dispatcher has failed. 10 Line 1111 exception: Unimplemented instruction 11 Miscellaneous exception: All other MC68000 exceptions 12 Unimplemented core routine: An unimplemented trap number was encountered. 13 Spurious interrupt: The interrupt vector table entry for a particular level of interrupt is NIL; usually occurs with level 4, 5, 6, or 7 interrupts. 14 1/0 system error: The File Manager is attempting to dequeue an entry from an 1/0 request queue that has a bad queue type field; perhaps the queue entry is unlocked. Or, the dCtlQHead field was NIL during a Fetch or Stash call. Or, a needed device control entry has been purged. 15 Segment Loader error: A GetResource call to read a segment into memory failed. 16 Floating point error: The halt bit in the floating-point environment word was set. 17-24 Can't load package: A GetResource call to read a package into memory failed. 25 Can't allocate requested memory block in the heap 26 Segment Loader error: A GetResource call to read 'CODE' resource 0 into memory failed; usually indicates a nonexecutable file. ///-176 System Error Handler Summary 27 File map destroyed: A logical block number was found that's greater than the number of the last logical block on the volume or less than the logical block number of the fi rst allocation block on the volume. 28 Stack overflow error: The stack has expanded into the heap. 30 "Please insert the disk:" File Manager alert 41 The file named "Finder" can't be found on the disk. 100 Can't mount system startup volume. The system couldn't read the system resource file into memory. 32767 "Sorry, a system error occurred": Default alert message System Startup Alerts "Welcome to Macintosh" "Disassembler installed" "MacsBug installed" "Warning-this startup disk is not usable" Assembly-Language Information Constants ; System error IDs dsBusError .EQU 1 ;bus error dsAddressErr . EQU 2 ;address error dsi ll i nstErr . EQU 3 ;illega l instruction ds ZeroDivErr . EQU 4 ; zero d ivide dsChkErr . EQU 5 ; chec k exception dsOvf lowErr . EQU 6 ;trapV exception ds Pri vErr . EQU 7 ;pr ivilege violation dsTraceErr . EQU 8 ; trace exception dsLineAErr . EQU 9 ;line 1010 exception dsLineFErr . EQU 10 ; l ine 1111 exception dsMi scErr . EQU 11 ;miscell aneous exception d sCoreErr . EQU 12 ;unimplemented core rout i ne ds irqErr . EQU 13 ;spurious inter rupt dsIOCoreErr .EQU 14 ;I/O system error dsLoadEr r . EQU 15 ;Segment Loader error dsFPErr .EQU 16 ;floating point error dsNoPackErr .EQU 17 ;can ' t load package 0 dsNoPkl .EQU 18 ;can ' t l oad package 1 dsNoPk2 . EQU 19 ;can ' t load package 2 dsNoPk3 . EQU 20 ;can't load package 3 dsNoPk4 . EQU 21 ; can 't load package 4 dsNoPkS . EQU 22 ; c an ' t load package 5 dsNoPk6 . EQU 23 ;can ' t load package 6 System Error Handler /11-1 77 Inside Macintosh dsNoPk7 .EQU 24 ;can ' t load package 7 dsMernFullErr . EQU 25 ;can ' t allocate requested block dsBad.Launch .EQU 26 ;Segment Loader error dsFSErr .EQU 27 ;file map destroyed dsStkNHeap .EQU 28 ;stack overflow error dsReinsert .EQU 30 ;"Please insert the disk:" dsSysErr .EQU 32767 ;undifferentiated system error Routines Trap macro On entry On exit _SysError DO: errorCode (word) All registers changed Variabl es DSErrCode Current system error ID (word) DSAlertTab Pointer to system error alert table in use DSAlertRect Rectangle enclosing system error alert (8 bytes) l//-178 System Error Handler Summary TEXTEDIT Constants CONST { Text justification teJustLeft O; teJustCenter l; teJustRight -1; Data Types TYPE TEHandle = "TEPtr; TEPtr = "TERec; TERec = RECORD destRect: Rect; {destination rectangle} viewRect: Rect; {view rectangle} selRect: Rect; {used from assembly language} lineHeight INTEGER; {for l ine spacing fontAscent: INTEGER; {caret/highlighting position} selPoint: Point; {used from assembly language} selStart: INTEGER; {start of selection range} selEnd: INTEGER; {end of selection range active: INTEGER; {used internally} word.Break : ProcPtr; {for word break routine} cli kLoop: ProcPtr; {for click loop routine} clickTime: LONGINT; {used internally} clickLoc: INTEGER; {used internally} caretTime : LONGINT ; {used internally} caretState : INTEGER; {used internally} just: INTEGER; {justification of text} teLength : INTEGER; {length of text} hText: Handle; {text to be edited} recalBack: INTEGER; {used internally} recalLines: INTEGER; {used internally} clikStuff : INTEGER; {used internally} crOnly: INTEGER; {if <0 , new line at Return only} txFont: INTEGER; {text font} txFace: Style; {character style} txMode : INTEGER; {pen mode} txSize: INTEGER; {font size } inPort: Graf Pt r; {grafPort} highHook: ProcPtr ; {used from assembly language} caretHook: ProcPtr; {used from assembly language} nLines: INTEGER; {number of lines } lineStarts: ARRAY[0 .. 16000) OF INTEGER {positions of line starts} END; TextEdit J!I-179 Inside Macintosh Chars Handle = "'CharsPtr; CharsPtr = "'Chars; Chars =PACKED ARRAY[O • • 32000] OF CHAR; Routines Initialization and Allocation PROCEDURE TEinit; FUNCTION TENew (destRect,viewRect: Rect) TEHandle; PROCEDURE TEDispose (hTE: TEHandle); Accessing the Text of an Edit Record PROCEDURE TESetText (text: Ptr; length: LONGINT; hTE : TEHandle) ; FUNCTION TEGetText (hTE: TEHandle) : CharsHandle; Insertion Point and Selection Range PROCEDURE TEidle (hTE: TEHandle); PROCEDURE TEClick (pt: Point; extend: BOOLEAN; hTE : TEHandle); PROCEDURE TESetSelect (selStart , selEnd: LONGINT ; hTE: TEHandle); PROCEDURE TEActivate (hTE: TEHandle); PROCEDURE TEDeactivate (hTE: TEHandle); Editing PROCEDURE TEKey (key: CHAR; hTE: TEHandl e ); PROCEDURE TECut (hTE: TEHandle); PROCEDURE TECopy (hTE : TEHandle); PROCEDURE TEPaste (hTE : TEHandle); PROCEDURE TEDelete (hTE: TEHandle) ; PROCEDURE TEinsert (text: Ptr; length: LONGINT; hTE: TEHandle); Text Display and Scrolling PROCEDURE TESetJust (just : INTEGER; hTE: TEHandle); PROCEDURE TEUpdate (rUpdate: Rect; hTE: TEHandle); PROCEDURE TextBox (text: Ptr; length: LONGINT; box: Rect; just : INTEGER); PROCEDURE TEScroll (dh , dv: INTEGER; hTE: TEHandle); III-180 TextEdit Summary Scrap Handling [Not in ROM] FUNCTION TEFrornScrap OSErr; FUNCTION TEToScrap OSErr; FUNCTION TEScrapHandle Handle; FUNCTION TEGetScrapLen LONGINT; PROCEDURE TESetScrapLen (l ength: LONGINT); Advanced Routines PROCEDURE SetWord.Br eak (wBrkProc: ProcPtr; hTE : TEHandle); [Not in ROM] PROCEDURE SetClikLoop (clikProc : ProcPtr; hTE: TEHandle); [Not in ROM] PROCEDURE TECa l Text (hTE: TEHandl e); Word Break Routine FUNCTION MyWord.Break (text : Ptr; charPos: INTEGER) BOOLEAN; Click Loop Routine FUNCTION MyClikLoop : BOOLEAN; Assembly-Language Information Constants ; Text justification teJustLeft .EQU 0 teJustCenter .EQU 1 teJustRight . EQU -1 Edit Record Data Structure teDestRect Destination rectangle (8 bytes) teViewRect View rectangle (8 bytes) teSelRect Selection rectangle (8 bytes) teLineHite For line spacing (word) teAscent Caret/highlighting position (word) teSelPoint Point selected with mouse (long) teSelStart Start of selection range (word) teSe!End End of selection range (word) teWordBreak Address of word break routine (see below) teClikProc Address of click loop routine (see below) teJust Justification of text (word) TextEdit l!!-181 Inside Macintosh teLength Length of text (word) teTextH Handle to text teCROnly If <0, new line at Return only (byte) teFont Text font (word) teFace Character style (word) tcMode Pen mode (word) teSize Font size (word) teGrafPort Pointer to grafPort teHiHook Address of text highlighting routine (see below) teCarHook Address of routine to draw caret (see below) teNLines Number of lines (word) teLines Positions of line starts (teNLines*2 bytes) teRecSize Size in bytes of edit record except teLines field Word break routine On entry AO: pointer to text DO: character position (word) On exit Z condition code: 0 to break at specified character 1 not to break there Click loop routine On exit DO: 1 D2: must be preserved Text highlighting routine On entry A3: pointer to locked edit record Caret drawing routine On entry A3: pointer to locked edit record Variables TEScrpHandle Handle to TextEdit scrap TEScrpLength Size in bytes ofTextEdit scrap (word) TERecal Address of routine to recalculate line starts (see below) IBDoText Address of multi-purpose routine (see below) TERecal routine On entry A3: pointer to locked edit record D7: change in length of edit record (word) On exit D2: line start of line containing first character to be redrawn (word) D3: position of first character to be redrawn (word) D4: position oflast character to be redrawn (word) III-182 TextEdit Summary TEDoText routine On entry A3: pointer to locked edit record D3: position of first character to be redrawn (word) D4: position of last character to be redrawn (word) D7: (word) 0 to hit-test a character 1 to highlight selection range - 1 to display text - 2 to position pen to draw caret On exit AO: pointer to current grafPort DO: if hit-testing, character position or-1 for none (word) TextEdit Ill-1 83 Inside Macintosh UTILITIES, OPERATING SYSTEM Constants CONST { Values returned by Environs procedure macXLMachine 0; {Macintosh XL} macMachine l; {Macintosh 128K or 512K} { Result codes } clkRdErr -85; {unable to read clock} c lkWrErr - 86; {time written did not verify} memFullErr -108; {not enough room in heap zone} memWZErr -111; {attempt to operate on a free block} nilHandleErr - 109; {NIL master pointer} noErr 0; {no error} prinitErr -88; {validity status is not $A8} prWrErr -87; {parameter RAM written did not verify} qErr -1; {entry not in specified queue} Data Types TYPE OSType = PACKED ARRAY [ 1 .. 4] OF CHAR; OSErr = INTEGER; SysPPtr "SysParmType; SysParmType RECORD valid: Byte; {validity status } aTalkA: Byte; {AppleTalk node ID hint for modem port} aTalkB : Byte; {AppleTalk node ID hint for printer port} conf ig: Byte; {use types for serial ports} portA: INTEGER; {modem port configuration} portB : I NTEGER; {printer port configuration} alarm: LONGINT; {alarm setting} font : INTEGER; {application font number minus 1} kbdPrint: INTEGER; {auto- key settings, printer connection} volClik: INTEGER; {speaker volume, double-click, caret blink} misc: INTEGER {mouse scaling, startup disk, menu blink) END; QHdrPtr "QHdr; QHdr RECORD qFlags: INTEGER; {queue fl ags } qHead: QElemPtr; {first queue entry) qTail : QElemPtr {last queue ent ry} END; III-184 Utilities, Operating System Summary QTypes (durrunyType, vType, {vertical retrace queue type} ioQType , {file I/0 or driver I/O queue type } . drvQType, {drive queue type} evType, {event queue type} fsQType); {volume-control-block queue type} QElemPtr = "QE lem; QE l em RECORD CASE QTypes OF vType: (vblQElem : VBLTask); ioQType: (ioQElem: ParamBlockRec) ; drvQType: (drvQElem: DrvQEl); evType: (evQElem: EvQEl); fsQType: (vcbQElem: VCB) END; DateTimeRec = RECORD year: INTEGER; (1904 to 2040} month: INTEGER; (1 to 12 for January to December} day: INTEGER; {l to 31} hour: INTEGER; (0 to 23} minute: INTEGER; (0 to 59} second: INTEGER; {O to 59} dayOfWeek: INTEGER {l to 7 for Sunday to Saturday} END; Routines Pointer and Handle Manipulation FUNCTION HandToHand (VAR theHndl: Handl e) : OSErr; FUNCTION PtrToHand (srcPtr: Ptr; VAR dstHndl: Handle; size : LONG INT) OSErr; FUNCTION PtrToXHand (srcPtr: Ptr; dstHndl: Handle; size: LONGINT) : OSErr; FUNCTION HandAndHand (aHndl , bHndl: Handle) : OSErr; FUNCTION PtrAndHand (pntr: Ptr; hndl: Handle; size : LONGINT) OSErr; String Comparison FUNCTION EqualString (aStr,bStr: Str255; caseSens , diacSens: BOOLEAN) BOOLEAN; PROCEDURE UprString (VAR theString: Str255; diacSens : BOOLEAN); Utilities, Operating System /1/-1 85 Inside Macintosh Date and Time Operations FUNCTION Read.DateTime (VAR secs: LONGINT) : OSErr; PROCEDURE GetDateTime (VAR secs: LONG INT) ; [Not in ROM] FUNCTION SetDateTime (secs: LONGINT) : OSErr; PROCEDURE Date2Secs (date: DateTimeRec; VAR secs: LONGINT); PROCEDURE Secs2Date (secs: LONGINT; VAR date: DateTimeRec); PROCEDURE GetTime (VAR date: DateTimeRec) ; [Not in ROM] PROCEDURE SetTime (date: DateTimeRec); [NotinROM] Parameter RAM Operations FUNCTION InitUtil : OSErr; FUNCTION GetSysPPtr SysPPt r; [Not in ROM] FUNCTION WriteParam OSErr; Queue Manipulation PROCEDURE Enqueue (qEntry: QElemPtr; theQueue: QHdrPtr); FUNCTION Dequeue (qEntry: QElemPtr; theQueue: QHdrPtr) : OSErr; Trap Dispatch Table Utilities PROCEDURE SetTrapAddress (trapAddr: LONGINT; trapNum : INTEGER); FUNCTION GetTrapAddress (trapNum: INTEGER) : LONGINT; Miscellaneous Utilities PROCEDURE Delay (numTicks: LONGINT; VAR finalTic ks: LONGINT) ; PROCEDURE SysBeep (duration: INTEGER); PROCEDURE Environs (VAR rom,rnachine: INTEGER); [NotinROM] PROCEDURE Restart; [Not in ROM] PROCEDURE SetUpA5; [Not in ROM] PROCEDURE RestoreA5; [Not in ROM] Default Parameter RAM Values Parameter Default value Validity status $A8 Node ID hint for modem port 0 Node ID hint for printer port 0 Use types for serial ports 0 (both ports) Modem port configuration 9600 baud, 8 data bits, 2 stop bits, no parity ///-186 Utilities, Operating System Summary Parameter Default value Printer port configuration Same as for modem port Alarm setting 0 (midnight, January 1, 1904) Application font number minus 1 2 (Geneva) Auto-key threshold 6 (24 ticks) Auto-key rate 3 (6 ticks) Printer connection 0 (printer port) Speaker volume 3 (medium) Double-click time 8 (32 ticks) Caret-blink time 8 (32 ticks) Mouse scaling 1 (on) Preferred system startup disk 0 (internal drive) Menu blink 3 Assembly-Language Information Con stants ; Result codes clkRdErr .EQU -85 ;unable to read clock clkWrErr .EQU - 86 ;time written did not verify memFullErr .EQU -108 ;not enough room in heap zone memWZErr .EQU -111 ;attempt to operate on a free block nilHandleErr .EQU -109 ;NIL master pointer no Err .EQU 0 ;no error prinitEr r .EQU -88 ;validity status is not $A8 prWrErr .EQU -87 ;parameter RAM written did not ve rify qErr .EQU -1 ;entry not in specified queue ; Queue types vType .EQU 1 ;vertical retrace queue type ioQType .EQU 2 ;file I/0 or driver I/0 queue type drvQType .EQU 3 ;drive queue type evType .EQU 4 ;event queue type fsQType .EQU 5 ;volume-control- block queue type Qu eue Data Stru cture qFlags Queue flags (word) qHead Pointer to first queue entry qTail Pointer to last queue entry Utilities, Operating System III-187 Inside Macintosh Date/Time Record Data Structure dtYear 1904 to 2040 (word) dtMonth 1 to 12 for January to December (word) dtDay 1 to 31 (word) dtHour 0 to 23 (word) dtMinute 0 to 59 (word) dtSecond 0 to 59 (word) dtDayOfWeek 1 to 7 for Sunday to Saturday (word) Routines Trap macro On entry On exit HandToHand AO: theHndl (handle) AO: theHndl (handle) DO: result code(word) _PuToHand AO: srcPtr (ptr) AO: dstHndl (handle) DO: size (long) DO: result code (word) PuToXHand AO: srcPtr (ptr) AO: dstHndl (handle) A 1: dstHndl (handle) DO: result code (word) DO: size (long) _ HandAndHand AO: aHndl (handle) AO: bHndl (handle) Al : bHndl (handle) DO: result code (word) _PtrAndHand AO: pntr (ptr) AO: hndl (handle) A 1: hndl (handle) DO: result code (word) DO: size (long) _CmpString _CmpString ,MARKS sets bit 9, for diacSens=FALSE _CmpString ,CASE sets bit 10, for caseSens=TRUE _CmpString ,MARKS,CASE sets bits 9 and 10 AO: ptr to first string DO: 0 if equal, I if Al : ptr to second string not equal (long) DO: high word: length of first string low word: length of second string _UprString _UprString ,MARKS sets bit 9, for diacSens=FALSE AO: ptr to string AO: ptr to string DO: length of string (word) _ReadDateTime AO: ptr to long word secs AO: ptr to long word secs DO: result code (word) SetDateTime DO: secs (long) DO: result code (word) Date2Secs AO: ptr to date/time record DO: secs (long) Secs2Date DO: secs (long) AO: ptr to date/time record InitUtil DO: result code (word) WriteParam AO: SysParam (ptr) DO: result code (word) DO: MinusOne (long) III-188 Utilities, Operating System Summary Trap macro On entry On exit _Enqueue AO: qEntry (ptr) Al: theQueue (ptr) Al: theQueue (ptr) _Dequeue AO: qEntry (ptr) A 1: theQueue (ptr) A 1: theQueue (ptr) DO: result code (word) _ GetTrapAddress DO: trapNum (word) AO: address of routine _ SetTrapAddress AO: trapAddr (address) DO: trapNum (word) _Delay AO: numTicks (long) DO : finalTicks (long) _SysBeep stack: duration (word) Variables SysParam Low-memory copy of parameter RAM (20 bytes) SPValid Validity status (byte) SPATalkA AppleTalk node ID hint for modem port (byte) SPATalkB AppleTalk node ID hint for printer port (byte) SPConfig Use types for serial ports (byte) SPPortA Modem port configuration (word) SPPortB Printer port configuration (word) SPAlarm Alarm setting (long) SPFont Application font number minus 1 (word) SPKbd Auto-key threshold and rate (byte) SPPrint Printer connection (byte) SPVolCtl Speaker volume (byte) SPClikCaret Double-click and caret-blink times (byte) SPMisc2 Mouse scaling, system startup disk, menu blink (byte) CrsrThresh Mouse-scaling threshold (word) Time Seconds since midnight, January 1, 1904 (long) Utilities, Operating System IIl-189 Inside Macintosh UTILITIES, TOOLBOX Constants CONST { Resource ID of standard pattern list ) sysPatListID = O; { Resource IDs of standard cursors iBeamCursor 1; {to select text ) crossCursor 2; {to draw graphics) plusCursor 3; {to select cells in structured documents) watchCursor 4; {to indicate a long wait) Data Types TYPE Int64Bit = RECORD hiLong: LONGINT; loLong: LONGINT END; CursPtr "Cursor; CursHandle "CursPt r; PatPtr "Pattern; PatHandle "PatPtr; Routines Fixed-Point Arithmetic FUNCTION Fi xRatio (nurner,denom: INTEGER) Fixed; FUNCTION Fi xMul (a , b: Fixed) : Fixed; FUNCTION FixRound (x: Fixed) : INTEGER; String Manipulation FUNCTION NewString (theString: Str255) : StringHandle; PROCEDURE SetString (h: StringHandle; theString: Str255); FUNCTION GetString (stringID: INTEGER) : StringHandle; PROCEDURE GetindString (VAR theString: Str255; strListID: INTEGER; index: INTEGER) ; [Not in ROM] III-190 Utilities, Toolbox Summary Byte Manipulation FUNCTION Munger (h: Handle; offset: LONGINT; ptrl: Ptr; lenl: LONGINT; ptr2: Ptr; len2: LONGINT) : LONGINT; PROCEDURE Pack.Bits (VAR srcPtr,dstPtr: Ptr; srcBytes: INTEGER); PROCEDURE UnpackBits (VAR srcPtr,dstPtr: Ptr; dstBytes: INTEGER); Bit Manipulation FUNCTION BitTst (bytePtr: Ptr; bitNum: LONG INT) : BOOLEAN; PROCEDURE BitSet (bytePtr: Ptr; bitNum: LONGINT); PROCEDURE BitClr (bytePtr: Ptr; bitNum: LONGINT); Log ical Operati ons FUNCTION BitAnd (valuel,value2: LONGINT) LONGINT; FUNCTION BitOr (valuel,value2: LONGINT) LONGINT; FUNCTION BitXor (valuel , value2: LONGINT) LONGINT; FUNCTION BitNot (value: LONGINT) : LONGINT; FUNCTION BitShift (value: LONGINT; count: INTEGER) : LONGINT; Other Operations on Long Integers FUNCTION HiWord (x: LONGINT) : INTEGER; FUNCTION LoWord (x: LONGINT) : INTEGER; PROCEDURE LongMul (a,b : LONGINT; VAR dest: Int64Bit); Graphics Uti lities PROCEDURE ScreenRes (VAR scrnHRes, scrnVRes : INTEGER) ; [Not in ROM] FUNCTION Geticon (iconID: INTEGER) : Handle; PROCEDURE Ploticon (theRect: Rect; thereon: Handle); FUNCTION GetPattern (patID: INTEGER) : PatHandle; PROCEDURE GetindPattern (VAR thePattern: Pattern; patListID: INTEGER; index: INTEGER) ; [Not in ROM] FUNCTION GetCursor (cursorID: INTEGER) : CursHandle; PROCEDURE ShieldCursor (shieldRect: Rect; offsetPt: Point); FUNCTION GetPicture (picID: INTEGER) : PicHandle; Miscellaneous Utiliti es FUNCTION DeltaPoint (ptA,ptB: Point) : LONGINT; FUNCTION SlopeFromAngle (angle: INTEGER) : Fixed; FUNCTION AngleFromSlope (slope: Fixed) : INTEGER; Utilities, Toolbox III-191 Inside Macintosh Assembly-Language Information Constants ; Resource ID of standard pattern list sysPatListID .EQU 0 ; Resource IDs of standard cursors iBeamCursor . EQU 1 ;to select text crossCursor .EQU 2 ;to draw graphics plusCursor . EQU 3 ;to select cells in structured documents watchCursor . EQU 4 ;to indicate a l ong wait Variables ScrVRes Pixels per inch vertically (word) ScrHRes Pixels per inch horizontally (word) 111-192 Utilities, Toolbox Summary VERTICAL RETRACE MANAGER Constants CONST { Result codes noErr = 0; {no error} qErr = -1; {task entry isn ' t in the queue} vTypErr = -2; {qType field isn't ORD(vType)} Data Types TYPE VBLTask = RECORD qLink: QElernPtr; {next queue entry} qType : INTEGER; {queue type} vblAddr: ProcPtr; {pointer to task} vblCount: INTEGER; {task frequency} vblPhase: INTEGER {task phase} END; Routines FUNCTION VInstall (vblTaskPtr: QElemPtr) OSErr; FUNCTION VRemove (vblTaskPtr: QElemPtr) OSErr; FUNCTION GetVBLQHdr QHdrPtr; [Not in ROM] Assembly-Language Information Constants inVBL .EQU 6 ;set if Vertical Retrace Manager is executing a task ; Result codes noErr .EQU 0 ;no error qErr .EQU -1 ;task entry isn ' t in the queue vTypErr .EQU -2 ;qType field isn't vType Structure of Vertical Retrace Queue Entry qLink Pointer to next queue entry qType Queue type (word) vblAddr Address of task vblCount Task frequency (word) vblPhase Task phase (word) Vertical Retrace Manager lll-193 Inside Macinwsh Routines Trap macro On entry On exit Vlnstall AO: vblTaskPtr (ptr) DO: result code (word) VRemove AO: vblTaskPtr (ptr) DO: result code (word) Variables VBLQueue Vertical retrace queue header ( 10 bytes) IIJ-1<)4. Vertical Retrace Manager Summary WINDOW MANAGER Constants CONST { Window definition IDs } documentProc 0; {standard document window} c!BoxProc 1; {alert box or modal dialog b ox} plainDBox 2; {plain box} altDBoxProc 3; {plain box with shadow} noGrowDocProc 4; {document window without s i ze box } rDocProc 16; {rounded- corner window} { Window class, in windowKind field of window r e c ord } dialogKind 2; {dialog or alert window} userKind 8; {window created directly by the applicat i on } { Values returned by FindWindow inDesk 0; {none of the following} inMenuBar l; {in menu bar} inSysWindow 2; {in system window} inContent 3; {in content region (except grow, if active ) } inDrag 4; {in drag region} inGrow 5; {in grow region (active window only) } inGoAway 6; {in go- away region (active wi ndow only ) } { Axis constraints for DragGrayRgn noConstraint O; {no constraint} hAxisOnly 1; {horizontal axis only} vAxisOnly 2; {vertical axis only} { Messages to window definition function wDraw O; {draw window frame} wHit l; {tell what region mouse button was pres sed i n} wCalcRgns 2; {calculate strucRgn and contRgn} wNew 3; {do any additional window initializat i on} wDispose 4; {take any additional disposal actions } wGrow 5; {draw window's grow image} wDrawGicon 6; {draw size box in content region} { Values returned by window definition function's hit routine } wNoHit O; {none of t he following} winContent 1; {in content region (except grow, i f active) } winDrag 2; {in drag region} winGrow 3; {in grow region (active window only ) } winGoAway 4; {in go-away region (active window only) } Window Manager JII-195 Inside Macintosh { Resource ID of desktop pattern } deskPatID = 16; Data Types TYPE WindowPtr GrafPtr; WindowPeek "WindowRecord; WindowRecord RECORD port: Graf Port; {window ' s grafPort} windowKind: INTEGER; {window class} visible: BOOLEAN; {TRUE if visible} hilited: BOOLEAN; {TRUE if highlighted} goAwayFlag: BOOLEAN; {TRUE if has go-away region } spareFlag: BOOLEAN; {reserved f or future use} strucRgn: RgnHandle; {structure region} contRgn: RgnHandle; {content region} updateRgn: RgnHandle; {update region} windowDefProc: Handle; {window definition function} dataHandle: Handle; {data used by windowDefProc} titleHandle : StringHandle; {window 's title} titleWidth: INTEGER; {width of title in pixels} controlList: ControlHandle; {window's control l ist} nextWindow: WindowPeek; {next window in window l ist} windowPic: PicHandle ; {picture for drawing window } refCon: LONG INT {window's reference value} END; Routines Initialization and Allocation PROCEDURE InitWindows; PROCEDURE GetWMgrPort (VAR wPort: GrafPtr); FUNCTION NewWindow (wStorage : Ptr; boundsRect: Rect; title : Str255; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT) : WindowPtr; FUNCTION GetNewWindow (windowID: INTEGER; wStorage: Ptr; behind: WindowPtr) : WindowPtr; PROCEDURE CloseWindow (theWindow: WindowPtr); PROCEDURE DisposeWindow (theWindow: WindowPtr); III-196 Window Manager Summary Window Display PROCEDURE SetWTitle (theWindow: WindowPtr; title: Str25 5); PROCEDURE GetWTitle (theWindow : WindowPtr; VAR tit l e : Str255) ; PROCEDURE Select Window (theWindow: WindowPtr); PROCEDURE HideWindow (t heWi ndow : WindowPtr) ; PROCEDURE ShowWindow (theWindow : WindowPtr); PROCEDURE ShowHide (theWindow : WindowPtr; showFlag : BOOLEAN) ; PROCEDURE HiliteWindow (theWindow : WindowPtr; fHilite: BOOLEAN) ; PROCEDURE BringToFront (theWindow : WindowPtr) ; PROCEDURE SendBehind (theWindow,behindWindow: WindowPtr); FUNCTION FrontWindow : WindowPtr; PROCEDURE Dr awGr owicon (theWindow : Wi ndowPtr) ; Mouse Location FUNCTION FindWindow (thePt: Point ; VAR whichWindow: WindowPtr ) : INTEGER; FUNCTION TrackGoAway (theWindow : WindowPtr; thePt : Point ) : BOOLEAN; Window Movement and Sizing PROCEDURE MoveWindow (theWindow: WindowPtr; hGlobal, vGloba l : INTEGER; front : BOOLEAN) ; PROCEDURE DragWi ndow (theWindow: WindowPtr; startPt : Point ; boundsRect : Rect); FUNCTION GrowWindow (theWindow : WindowPtr ; startPt : Point ; sizeRect : Rect) : LONGINT; PROCEDURE SizeWindow (theWi ndow: WindowPtr; w, h: INTEGER; f Update: BOOLEAN); Update Reg ion Maintenance PROCEDURE I nvalRect (badRect : Rect) ; PROCEDURE InvalRgn (badRgn : RgnHandle) ; PROCEDURE ValidRect (goodRect : Rect ) ; PROCEDURE ValidRgn (goodRgn : RgnHandle); PROCEDURE BeginUpdate (theWindow : WindowPtr); PROCEDURE EndUpdate (theWindow: WindowPtr); Miscellaneous Routines PROCEDURE SetWRefCon (theWindow : WindowPtr; data : LONGINT) ; FUNCTION GetWRefCon (theWindow : WindowPtr) : LONGINT; PROCEDURE SetWindowPic (theWindow : WindowPtr; pie: Pi cHa ndl e ) ; FUNCTION GetWindowPic (theWindow : WindowPtr) : PicHandle ; FUNCTION PinRect (theRect : Rect; thePt: Point) : LONGI NT; Window Manager lll-197 Inside Macintosh FUNCTION DragGrayRgn (theRgn: RgnHandle; startPt: Point; limitRect, slopRect: Rect; axis: INTEGER; actionProc: ProcPtr) : LONGINT; Low-Level Routines FUNCTION CheckUpdate (VAR theEvent: EventRecord) BOOLEAN; PROCEDURE ClipAbove (window: WindowPeek); PROCEDURE SaveOld (window: WindowPeek); PROCEDURE DrawNew (window: WindowPeek; update: BOOLEAN); PROCEDURE PaintOne (window: WindowPeek ; clobberedRgn: RgnHandle); PROCEDURE PaintBehind (startWindow : WindowPeek; clobberedRgn: RgnHandle) ; PROCEDURE CalcVis (window: WindowPeek); PROCEDURE CalcVisBehind (startWindow: WindowPeek; clobberedRgn: RgnHandle) ; Diameters of Curvature for Rounded-Corner Windows Window definition ID Diameters of curvature rDocProc 16, 16 rDocProc + 1 4,4 rDocProc + 2 6, 6 rDocProc + 3 8, 8 rDocProc + 4 10, 10 rDocProc + 5 12, 12 rDocProc + 6 20, 20 rDocProc + 7 24,24 Window Definition Function FUNCTION MyWindow (varCode: INTEGER; theWindow: WindowPtr; message : INTEGER; param: LONGINT) : LONGINT; Assembly-Language Information Constants ; Window definition IDs doctunentProc .EQU 0 ;standard document window dBoxProc .EQU 1 ;alert box or modal dialog box plainDBox .EQU 2 ;plain box III-198 Window Manager Summary altDBoxProc .EQU 3 ;plain box with shadow noGrowDocProc .EQU 4 ;document window without size box rDocProc .EQU 16 ;rounded-comer window ; Window class, in windowKind field of window record dialogKind .EQU 2 ;dialog or alert window userKind .EQU 8 ;window created directly by the application ; Values returned by FindWindow inDesk .EQU 0 ;none of the following inMenuBar .EQU 1 ;in menu bar inSysWindow .EQU 2 ; in system window inContent .EQU 3 ; in content region (except grow, if active) inDrag .EQU 4 ;in drag region inGrow .EQU 5 ;in grow region (active window only) inGoAway .EQU 6 ;in go-away region (active window only) ; Axis constraints for DragGrayRgn noConstraint .EQU 0 ;no constraint hAxisOnly .EQU 1 ;horizontal axis only vAxisOnly .EQU 2 ;vertical axis only ; Messages to window definition function wDrawMsg .EQU 0 ;draw window frame wHitMsg .EQU 1 ;tell what region mouse button was pressed in wCalcRgnMsg .EQU 2 ;calculate strucRgn and contRgn winitMsg . EQU 3 ; do any additional window initialization wDisposeMsg .EQU 4 ;take any additional disposal actions wGrowMsg .EQU 5 ;draw window's grow image wGiconMsg .EQU 6 ;draw size box in content region ; Value returned by window definition function's hit routine wNoHit .EQU 0 ;none of the following winContent .EQU 1 ; in content region (except grow, i f active) winDrag . EQU 2 ; in drag region winGrow .EQU 3 ; in grow region (active window only) winGoAway .EQU 4 ;in go-away region (active window only) ; Resource ID of desktop pattern deskPatID .EQU 16 Window Record Data Structure windowPort Window's grafPort (portRec bytes) window Kind Window class (word) wVisible Nonzero if window is visible (byte) wHilited Nonzero if window is highlighted (byte) Window Manager III-199 Inside Macintosh wGoAway Nonzero if window has go-away region (byte) structRgn Handle to structure region of window contRgn Handle to content region of window updateRgn Handle to update region of window windowDef Handle to window definition function wDataHandle Handle to data used by window definition function wTitleHandle Handle to window's title (preceded by length byte) wTitleWidth Width of title in pixels (word) wControlList Handle to window's control list nextWindow Pointer to next window in window list windowPie Picture handle for drawing window wRefCon Window's reference value (long) windowSize Size in bytes of window record Special Macro Names Pascal name Macro name CaleVisBehind CalcVBehind DisposeWindow _ DisposWindow DragGrayRgn _DragGrayRgn or, after setting the global variable DragPattem, _ DragTheRgn Variables WindowList Pointer to first window in window list SaveUpdate Flag for whether to generate update events (word) PaintWhite Flag for whether to paint window white before update event (word) CurActivate Pointer to window to receive activate event CurDeactive Pointer to window to receive deactivate event GrayRgn Handle to region drawn as desktop DeskPattem Pattern with which desktop is painted (8 bytes) DeskHook Address of procedure for painting desktop or responding to clicks on desktop WMgrPort Pointer to Window Manager port GhostWindow Pointer to window never to be considered frontmost DragHook Address of procedure to execute during TrackGoAway, DragWindow, GrowWindow, and DragGrayRgn DragPattem Pattern of dragged region's outline (8 bytes) OldStructure Handle to saved structure region OldContent Handle to saved content region SaveVisRgn Handle to saved visRgn l//-200 Window Manager Swnmary ASSEMBLY LANGUAGE Variables OneOne $00010001 MinusOne $FFFFFFFF Lo3Bytes $00FFFFFF Scratch20 20-byte scratch area Scratch8 8-byte scratch area ToolScratch 8-byte scratch area Appl Scratch 12-byte scratch area reserved for use by applications ROMBase Base address of ROM RAMBase Trap dispatch table's base address for routines in RAM CurrentA5 Address of boundary between application globals and application parameters Hardware Warning: This information applies only to the Macintosh 128K and 512K, not to the Macintosh XL. Constants ; VIA base addresses vBase .EQU $EFE1FE ;main base for VIA chip {in variable VIA) aVBufB .EQU vBase ; register B base aVBufA .EQU $EFFFFE ;register A base aVBufM .EQU aVBufB ;register containing mouse signals aVIFR .EQU $EFFBFE ;interrupt flag register a VIER .EQU $EFFDFE ;interrupt enable register ; Offsets from vBase vBufB . EQU 512*0 ;register B {zero offset) vDirB .EQU 512*2 ;register B direction register vDirA .EQU 512*3 ;register A direction register vTlC .EQU 512*4 ;timer 1 counter {low-order byte) vTlCH .EQU 512*5 ; timer 1 counter {high-order byte) vTlL .EQU 512*6 ; timer 1 latch {low-order byte) vTlLH .EQU 512*7 ;timer 1 latch (high-order byte) vT2C .EQU 512*8 ;timer 2 counter {low- order byte) vT2CH .EQU 512*9 ;timer 2 counter {high-order byte) vSR .EQU 512*10 ;shift register {keyboard) vACR .EQU 512*11 ;auxil iary control register vPCR .EQU 512*12 ;peripheral control register vIFR .EQU 512*13 ;interrupt flag register Assembly I..Anguage JJJ-201 Inside Macintosh vIER .EQU 512*14 ;interrupt enable register vBufA .EQU 512*15 ;register A ; VIA register A constants vAOut .EQU $7F ;direction register A: 1 bits = outputs vAinit .EQU $7B ;initial value f or vBufA (medium volume) vSound .EQU 7 ;sound volume bits ; VIA register A bit numbers vSnd.Pg2 .EQU 3 ;0 = alternate sound buffer vOverlay .EQU 4 ;1 = ROM overlay (system startup only) vHeadSel .EQU 5 ;disk SEL control line vPage2 .EQU 6 ;0 = alternate screen buffer vSCCWReq .EQU 7 ;SCC wait/request line ; VIA register B constants vBOut .EQU $87 ;direction register B: 1 bits outputs vBinit .EQU $07 ;initial value for vBufB ; VIA register B bit numbers rTCData .EQU 0 ;real-time clock serial data line rTCClk .EQU 1 ;real-time clock data-clock line rTCEnb .EQU 2 ;real-time clock serial enable vSW .EQU 3 ;O = mouse button is down vX2 .EQU 4 ;mouse X quadrature level vY2 .EQU 5 ;mouse Y quadrature level vH4 .EQU 6 ;1 horizontal blanking vSndEnb .EQU 7 ;0 = sound enabled, 1 = disabled ; sec base addresses sccRBase .EQU $9FFFF8 ;SCC base read address (in variable SCCRd) sccWBase .EQU $BFFFF9 ;SCC base write address (in variable SCCWr) ; Off sets from SCC base addresses aData .EQU 6 ;channel A data in or out aCtl .EQU 2 ;channel A control bData .EQU 4 ;channel B data in or out bCtl .EQU 0 ; channe l B control ; Bit numbers for contro l register RRO rxBF .EQU 0 ;1 sec receive buffer full txBE .EQU 2 ;l sec send buffer empty III-202 Assembly Language Swnmary ; IWM base address c!Base .EQU $DFE1FF ;IWM base address (in variable IWM) ; Offsets from c!Base phOL .EQU 512*0 ;CAO off (0) phOH .EQU 512*1 ;CAO on (1) phlL .EQU 512*2 ;CAl off (0) phlH .EQU 512*3 ;CAl on (1) ph2L .EQU 512*4 ;CA2 off (0) ph2H .EQU 512*5 ;CA2 on (1) ph3L . EQU 512*6 ; LSTRB off (low) ph3H .EQU 512*7 ;LSTRB on (high) mtrOf f .EQU 512*8 ;disk enable off mtrOn .EQU 512*9 ;disk enable on intDrive . EQU 512*10 ;select internal drive extDrive . EQU 512*11 ;select external drive q6L .EQU 512*12 ;Q6 off q6H .EQU 512*1 3 ;Q6 on q7L .EQU 512*14 ;Q7 off q7H .EQU 512*15 ;Q7 on Screen and sound addresses for 512K Macintosh (will also work for 128K, since addresses wrap) screenLow .EQU $7A700 ;top left corner of main screen buffer sound.Low .EQU $7FDOO ;main sound buffer (in variable Sounc!Base) pwmBuffer .EQU $7FD01 ;main disk speed buffer ovlyRAM .EQU $600000 ;RAM start address whe n overlay i s set ovlyScreen .EQU $67A700 ;screen start with overlay set romStart .EQU $400000 ;ROM start address (in variable ROMBase) Variables ROMBase Base address of ROM SoundBase Address of main sound buffer SCCRd sec read base address SCCWr sec write base address IWM IWM base address VIA VIA base address Exception Vectors Location Purpose $00 Reset: initial stack pointer (not a vector) $04 Reset: initial vector $08 Bus error Assembly Language JJJ-203 Inside Macintosh Location Purpose $0C Address error $10 Illegal instruction $14 Divide by zero $18 CHK instruction $1C TRAPV instruction $20 Privilege violation $24 Trace interrupt $28 Line 1010 emulator $2C Line 1111 emulator $30-$3B Unassigned (reserved) $3C Uninitialized interrupt $40-$5F Unassigned (reserved) $60 Spurious interrupt $64 VIA interrupt $68 sec interrupt $6C VIA+SCC vector (temporary) $70 Interrupt switch $74 Interrupt switch + VIA $78 Interrupt switch + SCC $7C Interrupt switch + VIA + SCC $80-$BF TRAP instructions $CO-$FF Unassigned (reserved) III-204 Assembly Language APPENDIX A: RESULT CODES This appendix lists all the result codes returned by the Macintosh system software. They're ordered by value, for convenience when debugging; the names you should actually use in your program are also listed. The result codes are grouped roughly according to the lowest level at which the error may occur. This doesn't mean that only routines at that level may cause those errors; higher-level software may yield the same result codes. For example , an Operating System Utility routine that calls the Memory Manager may return one of the Memory Manager result codes. Where a different or more specific meaning is appropriate in a different context, that meaning is also listed. Value Name Meaning 0 noErr No error Operating System Event Manager Error 1 evtNotEnb Event type not designated in system event mask Printing Manager Errors 128 iPrAbort Application or user requested abort -1 iPrSavPFil Saving spool file Queuing Errors -1 qErr Entry not in queue -2 vTypErr QType field of entry in vertical retrace queue isn't vType (in Pascal, ORD(vType)) Device Manager Errors -17 controlErr Driver can't respond to this Control call Unimplemented control instruction (Printing Manager) -18 statusErr Driver can't respond to this Status call -19 readErr Driver can't respond to Read calls -20 writErr Driver can't respond to Write calls -21 badUnitErr Driver reference number doesn't match unit table - 22 unitEmptyErr Driver reference number specifies NIL handle in unit table -23 openErr Requested read/write permission doesn't match driver's open permission Attempt to open RAM Serial Driver failed -25 dRemovErr Attempt to remove an open driver -26 dlnstErr Couldn't find driver in resource file Result Codes 111-205 Inside Macintosh -27 abortErr UO request aborted by KillIO iIOAbort UO abort error (Printing Manager) -28 notOpenErr Driver isn't open File Manager Errors - 33 dirFulErr File directory full -34 dskFulErr All allocation blocks on the volume are full - 35 nsvErr Specified volume doesn't exist - 36 ioErr UO error -37 bdNamErr Bad file name or volume name (perhaps zero-length) -38 fnOpnErr File not open -39 eofErr Logical end-of-file reached during read operation -40 posErr Attempt to position before start of file -42 tmfoErr Too many files open -43 fnfErr File not found -44 wPrErr Volume is locked by a hardware setting -45 fLckdErr File is locked -46 vLckdErr Volume is locked by a software flag -47 fBsyErr File is busy; one or more files are open -48 dupFNErr File with specified name and version number already exists -49 opWrErr The read/write permission of only one access path to a file can allow writing -50 paramErr Error in parameter list Parameters don't specify an existing volume, and there's no default volume (File Manager) Bad positioning information (Disk Driver) Bad drive number (Disk Initialization Package) - 51 rfNumErr Path reference number specifies nonexistent access path - 52 gfpErr Error during GetFPos - 53 volOffLinErr Volume not on-line -54 pennErr Attempt to open locked file for writing - 55 volOnLinErr Specified volume is already mounted and on-line - 56 nsDrvErr No such drive; specified drive number doesn't match any number in the drive queue -57 noMacDskErr Not a Macintosh disk; volume lacks Macintosh-format directory -58 extFSErr External file system; file-system identifier is nonzero, or path reference number is greater than 1024 III-206 Result Codes Result Codes -59 fsRnErr Problem during rename -60 badMDBErr Bad master directory block; must reinitialize volume -61 wrPermErr Read/write permission doesn't allow writing Low-Level Disk Errors -64 noDriveErr Drive isn't connected -65 offLinErr No disk in drive -66 noNybErr Disk is probably blank -67 noAdrMkErr Can't find an address mark -68 dataVerErr Read-verify failed -69 badCksmErr Bad address mark -70 badBtSlpErr Bad address mark -71 noDtaMkErr Can't find a data mark -72 badDCksum Bad data mark -73 badDBtSlp Bad data mark -74 wrUnderrun Write underrun occurred -75 cantStepErr Drive error -76 tkOBadErr Can't find track 0 -77 initIWMErr Can't initialize disk controller chip - 78 twoSideErr Tried to read side 2 of a disk in a single-sided drive -79 spdAdjErr Can't correctly adjust disk speed -80 seekErr Drive error - 81 sectNFErr Can't find sector Also, to check for any low-level disk error: -84 firstDskErr First of the range of low-level disk errors -64 lastDskErr Last of the range of low-level disk errors Clock Chip Errors -85 clkRdErr Unable to read clock -86 clkWrErr Time written did not verify -87 prWrErr Parameter RAM written did not verify -88 prlnitErr Validity status is not $A8 Result Codes III-207 Inside Macintosh AppleTalk Manager Errors -91 ddpSktErr DDP socket error: socket already active; not a well-known socket; socket table full; all dynamic socket numbers in use -92 ddpLenErr DDP datagram or ALAP data length too big -93 noBridgeErr No bridge found -94 lapProtErr ALAP error attaching/detaching ALAP protocol type: attach error when ALAP protocol type is negative, not in range, or already in table, or when table is full; detach error when ALAP protocol type isn't in table -95 excessCollsns ALAP no CTS received after 32 RTS's, or line sensed in use 32 times (not necessarily caused by collisions) -97 portlnUse Driver Open error, port already in use -98 portNotCf Driver Open error, port not configured for this connection Scrap Manager Errors -100 noScrapErr Desk scrap isn't initialized -102 noTypeErr No data of the requested type Memory Manager Errors - 108 memFullErr Not enough room in heap zone iMemFullErr Not enough room in heap zone (Printing Manager) - 109 nilHandleErr NIL master pointer - 111 memWZErr Attempt to operate on a free block -112 memPurErr Attempt to purge a locked block -117 memLockedErr Block is locked Resource Manager Errors -192 resNotFound Resource not found -193 resFNotFound Resource file not found - 194 addResFailed AddResource failed -196 rmvResFailed RmveResource failed Additional AppleTalk Manager Errors -1024 nbpBuffOvr NBP buffer overflow - 1025 nbpNoConfirm NBP name not confirmed -1026 nbpConfDiff NBP name confirmed for different socket -1027 nbpDuplicate NBP duplicate name already exists -1028 nbpNotFound NBP name not found III-208 Result Codes Result Codes -1029 nbpNISErr NBP names information socket error -1096 reqFailed ATPSndRequest failed: retry count exceeded -1097 tooManyReqs ATP too many concurrent requests -1098 tooManySkts ATP too many responding sockets -1099 badATPSkt ATP bad responding socket -1100 badBuffNum ATP bad sequence number -1101 noRelErr ATP no release received -1102 cbNotFound ATP control block not found -1103 noSendResp ATPAddRsp issued before ATPSndRsp -1104 noDataArea Too many outstanding ATP calls -1105 reqAborted Request aborted -3101 buf2SmallErr ALAP frame too large for buffer DDP datagram too large for buffer -3102 noMPPError MPP driver not installed -3 103 cksumErr DDP bad checksum -3104 extractErr NBP can't find tuple in buffer -3105 readQErr Socket or protocol type invalid or not found in table -3106 atpLenErr ATP response message too large -3107 atpBadRsp Bad response from A TPRequest - 3108 recNotFnd ABRecord not found -3109 sktClosedErr Asynchronous call aborted because socket was closed before call was completed Result Codes ///-209 Inside Macintosh III-210 APPENDIX B: ROUTINES THAT MAY MOVE OR PURGE MEMORY This appendix lists all the routines that may move or purge blocks in the heap. As described in chapter 1 of Volume II, calling these routines may cause problems if a handle has been dereferenced. None of these routines may be called from within an interrupt, such as in a completion routine or a VBL task. The Pascal name of each routine is shown, except for a few cases where there's no Pascal interface corresponding to a particular trap; in those cases, the trap macro name is shown instead (without its initial underscore character). AddResMenu Copy Bits DrawPicture Alert CopyRgn DrawString AppendMenu CouldAlert DrawText ATPAddRsp CouldDialog DriveStatus ATPCloseSocket CreateResFile Drvrlnstall ATPGetRequest DDPCloseSocket DrvrRemove ATPLoad DDPOpenSocket Eject ATPOpenSocket DDPRdCancel EmptyHandle ATPReqCancel DDPRead End Update ATPRequest DDPWrite EraseArc ATPResponse DialogSelect EraseOval ATPRspCancel DIBadMount ErasePoly ATPSndRequest DiffRgn EraseRect ATPSndRsp DIFonnat EraseRgn ATPUnload DILoad EraseRoundRect BeginUpdate DiskEject EventAvail BringToFront DisposDialog ExitToShell Button DisposeControl Fill Arc CalcMenuSize DisposeMenu FillOval CalcVis DisposeRgn Fill Poly CaleVisBehind DisposeWindow FillRect CautionAlert DisposHandle FillRgn Chain DisposPtr FillRoundRect ChangedResource DIUnload FindControl CharWidth DIVerify FlashMenuBar Checkltem DI.Zero FlushVol CheckUpdate DlgCopy FMSwapFont ClipAbove DlgCut Frame Arc ClipRect DigDelete FrameOval CloseDialog DlgPaste FramePoly ClosePicture DragControl FrameRect ClosePoly DragGray Rgn FrameRgn ClosePort DragWindow FrameRoundRect CloseResFile DrawChar FreeAlert CloseRgn DrawDialog FreeDialog CloseWindow DrawGrowIcon FreeMem CompactMem DrawMenuBar GetClip Control DrawNew GetCursor Routines That May Move or Purge Memory III-211 Inside Macintosh GetDCtlEntry IUCompString NumToString GetDitem IUDatePString OpenDeskAcc GetFNum IUDateString OpenPicture GetFontlnfo IUEqualString OpenPoly GetFontN ame IUGetlntl OpenPort Getlcon IUMagIDString OpenResFile GetlndPattem IUMagString OpenRgn GetlndResource IUMetric PaintArc GetlndString IUSetlntl PaintBehind GetKeys IUTimePString PaintOne GetMenu IUTimeString PaintOval GetMenuBar KillControls PaintPoly GetMouse KillPicture PaintRect GetNamedResource KillPoly PaintRgn GetNewControl LAPCloseProtocol PaintRoundRect GetNewDialog LAPOpenProtocol ParamText GetNewMBar LAPRdCancel PB Control GetNewWindow LAPRead PB Eject GetNextEvent LAPWrite PBFlushVol GetPattem Launch PBMountVol GetPicture Line PBOffLine GetResource LineTo PB Open GetScrap LoadResource PBOpenRF GetString LoadScrap PB Status GrowWindow LoadSeg PicComment HandAndHand MapRgn Plotlcon HandToHand Menu Key PrClose HideControl MenuSelect PrCloseDoc HideWindow ModalDialog PrClosePage HiliteControl MoreMasters PrCtlCall HiliteMenu MoveControl PrDrvrDCE HiliteWindow MoveHHi PrDrvrVers InitAllPacks MoveWindow PrintDefault InitApplZone MPPClose PrJobDialog InitFonts MPPOpen PrJobMerge InitMenus Munger PIOpen InitPack NBPConfirm PrOpenDoc InitPort NBPExtract PrOpenPage InitResources NBPLoad PrPicFile lnitWindows NBPLookup PrStlDialog InitZone NBPRegister PrValidate lnsertMenu NBPRemove PtrAndHand InsertResMenu NBPUnload PtrToHand InsetRgn NewControl PtI'foXHand InvalRect NewDialog PurgeMem InvalRgn NewHandle PutScrap InvertArc NewMenu RAMSDClose InvertOval NewPtr RAMSOOpen InvertPoly NewRgn RealFont InvertRect NewString ReallocHandle InvertRgn NewWindow RecoverHandle InvertRoundRect NoteAlert RectRgn 11/-212 Routines That May Move or Purge Memory Routines That May Move or Purge Memory ReleaseResource SetString TEActivate ResrvMem SetTagBuffer TECalText Restart SetWTitle TEClick RmveResource SFGetFile TECopy RsrcZonelnit SFPGetFile TECut SaveOld SFPPutFile TEDeactivate ScrollRect SFPutFile TEDelete SectRgn ShowControl TED is pose SelectWindow Show Hide TEFromScrap SellText ShowWindow TEGetText SendBehind SizeControl TEidle SerClrBrk SizeWindow TEI nit SerGetBrk StartSound TEinsert SerHShake Status TEKey SerReset StdArc TENew SerSetBrk StdBits TEPaste SerSetBuf StdComment TEScroll SerStatus StdLine TESetJust SetApplBase StdOval TESetSelect SetClip StdPoly TESetText SetCTitle StdPutPic TestControl SetCtlMax StdRect TEToScrap SetCtlMin StdRgn TEUpdate SetCtlValue StdRRect TextBox SetDitem StdText TextWidth SetEm ptyRgn StdTxMeas TickCount SetFontLock Still Down TrackControl SetHandleSize StopAlert TrackGoAway Seti tern StopSound UnionRgn Setltemlcon StringToNum UnloadScrap SetltemMark StringWidth UnloadSeg SetltemStyle SysBeep ValidRect SetlText SysError ValidRgn SetPtrSize SystemClick WaitMouseUp SetRectRgn SystemEdit XorRgn SetReslnfo SystemMenu ZeroScrap Routines That May Move or Purge Memory III-213 Inside Macintosh 111-214 APPENDIX C: SYSTEM TRAPS This appendix lists the trap macros for the Toolbox and Operating System routines and their corresponding trap word values in hexadecimal. The "Name" column gives the trap macro name (without its initial underscore character). In those cases where the name of the equivalent Pascal call is different, the Pascal name appears indented under the main entry. The routines in Macintosh packages are listed under the macros they invoke after pushing a routine selector onto the stack; the routine selector follows the Pascal routine name in parentheses. There are two tables: The first is ordered alphabetically by name; the second is ordered numerically by trap number, for use when debugging. (The trap number is the last two digits of the trap word unless the trap word begins with A9, in which case the trap number is 1 followed by the last two digits of the trap word.) Note: The Operating System Utility routines GetTrapAddress and SetTrapAddress take a trap number as a parameter, not a trap word. Warning: Traps that aren't currently used by the system are reserved for future use. Name Trap word Name T rap word AddDrive A04E ChangedResource A9AA (internal use only) CharWidth A88D AddPt A87E Checkltem A945 AddResMenu A94D CheckUpdate A911 AddResource A9AB ClearMenuBar A934 Alert A985 ClipAbove A90B Allocate AOlO ClipRect A87B PB Allocate Close AOOl AngleFromSlope A8C4 PBClose AppendMenu A933 CloseDeskAcc A9B7 BackColor A863 CloseDialog A982 BackPat A87C ClosePgon A8CC BeginUpdate A922 ClosePoly BitAnd A858 ClosePicture A8F4 BitClr A85F ClosePort A87D BitNot A85A CloseResFile A99A BitOr A85B CloseRgn A8DB BitSet A85E CloseWindow A92D BitShift A85C CmpString A03C BitTst A85D Equal String BitXor A859 ColorBit A864 BlockMove A02E CompactMem A04C BringToFront A920 Control A004 Button A974 PB Control CalcMenuSize A948 CopyBits A8EC CalcVBehind A90A CopyRgn A8DC CaleVisBehind CouldAlert A989 CalcVis A909 CouldDialog A979 CautionAlert A988 CountMitems A950 Chain A9F3 CountResources A99C System Traps Il/-215 Inside Macintosh Nam e Trap word Name Trap word CountTypes A99E EndUpdate A923 Create A008 Enqueue A96F PB Create Equal.Pt A881 CreateResFile A9Bl EqualRect A8A6 CurResFile A994 EqualRgn A8E3 Date2Secs A9C7 EraseArc A8CO Delay A03B EraseOval A8B9 Delete A009 ErasePoly A8C8 PB Delete EraseRect A8A3 DeleteMenu A936 EraseRgn A8D4 DeltaPoint A94F EraseRoundRect A8B2 Dequeue A96E ErrorSound A98C DetachResource A992 EventAvail A971 DialogSelect A980 ExitToShell A9F4 DiffRgn A8E6 FillArc A8C2 Disableltem A93A FillOval A8BB DisposControl A955 FillPoly A8CA DisposeControl FillRect A8A5 DisposDialog A983 FillRgn A8D6 DisposHandle A023 FillRoundRect A8B4 DisposMenu A932 FindControl A96C DisposeMenu FindWindow A92C DisposPtr AO IF FixMul A868 DisposRgn A8D9 FixRatio A869 DisposeRgn FixRound A86C DisposWindow A914 FlashMenuBar A94C DisposeWindow FlushEvents A032 DragControl A967 FlushFile A045 DragGrayRgn A905 PBFlushFile DragTheRgn A926 FlushVol A013 DragWindow A925 PB FlushVol DrawChar A883 FMSwapFont A901 DrawControls A969 ForeColor A862 DrawDialog A981 FP68K A9EB DrawGrowlcon A904 FrameArc A8BE DrawMenuBar A937 FrameOval A8B7 DrawNew A90F FramePoly A8C6 DrawPicture A8F6 FrameRect ASAI DrawString A884 FrameRgn A8D2 DrawText A885 FrameRoundRect A8BO Drvrlnstall A03D FreeAlert A98A (internal use only) FreeDialog A97A DrvrRemove A03E FreeMem AOIC (internal use only) FrontWindow A924 Eject A017 GetAppParms A9F5 PB Eject GetClip A87A Elems68K A9EC GetCRefCon A95A EmptyHandle A02B GetCTitle A95E EmptyRect A8AE GetCtlAction A96A EmptyRgn A8E2 GetCtlValue A960 Enableltem A939 GetCursor A9B9 III-216 System Traps System Traps Name Trap word Name Trap word GetDitem A98D GetScrap A9FD GetEOF AOll GetString A9BA PBGetEOF GetTrapAddress AI46 GetFilelnfo AOOC GetVol A014 PBGetFinfo PBGetVol GetFName A8FF GetVollnfo A007 GetFontName PBGetVInfo GetFNum A900 GetWindowPic A92F GetFontlnfo A88B GetWMgrPort A910 GetFPos A018 GetWRefCon A917 PBGetFPos GetWTitle A919 GetHandleSize A025 GetZone Al IA Getlcon A9BB GlobalToLocal A871 GetlndResource A99D GrafDevice A872 GetlndType A99F GrowWindow A92B Getltem A946 HandAndHand A9E4 GetIText A990 HandleZone AI26 Getltmlcon A93F HandToHand A9El Getltemlcon HideControl A958 GetltmMark A943 HideCursor A852 GetltemMark HidePen A896 GetltmStyle A941 HideWindow A916 GetltemStyle HiliteControl A95D GetKeys A976 HiliteMenu A938 GetMaxCtl A962 HiliteWindow A9IC GetCtlMax HiWord A86A GetMenuBar A93B HLock A029 GetMHandle A949 HNoPurge A04A GetMinCtl A961 HomeResFile A9A4 GetCtlMin HPurge A049 GetMouse A972 HUnlock A02A GetNamedResource A9Al Info Scrap A9F9 GetNewControl A9BE InitAllPacks A9E6 GetNewDialog A97C InitApplZone A02C GetNewMBar A9CO InitCursor A850 GetNewWindow A9BD InitDialogs A97B GetNextEvent A970 lnitFonts A8FE GetOSEvent A031 InitGraf A86E GetPattem A9B8 lnitMenus A930 GetPen A89A InitPack A9E5 GetPenState A898 InitPort A86D GetPicture A9BC lnitQueue A0 16 GetPixel A865 FinitQueue GetPort A874 InitResources A995 GetPtrSize A021 InitUtil A03F GetResAttrs A9A6 !nitWindows A912 GetResFileAttrs A9F6 InitZone A019 GetReslnfo A9A8 lnsertMenu A935 GetResource A9AO InsertResMenu A95 1 GetRMenu A9BF InsetRect A8A9 GetMenu InsetRgn A8El System Traps III-217 Inside Macintosh Name Trap word Name Trap word InvalRect A928 NewWindow A913 InvalRgn A927 NoteAlert A987 InverRect A8A4 ObscureCursor A856 lnvertRect Offiine A035 InverRgn A8D5 PBOffline InvertRgn OffsetPoly A8CE InverRoundRect A8B3 OffsetRect A8A8 InvertRoundRect OfsetRgn A8EO InvertArc A8Cl OffsetRgn InvertOval A8BA Open AOOO InvertPoly A8C9 PB Open lsDialogEvent A97F OpenDeskAcc A9B6 KillControls A956 OpenPicture A8F3 KillIO A006 OpenPoly A8CB PBKillIO OpenPort A86F KillPicture A8F5 OpenResFile A997 KillPoly A8CD OpenRF AOOA Launch A9F2 PBOpenRF Line A892 OpenRgn A8DA LineTo A891 OSEventAvail A030 LoadResource A9A2 PackO A9E7 LoadSeg A9FO (reserved for future use) LocalToGlobal A870 Packl A9E8 LodeScrap A9FB (reserved for future use) LoadScrap Pack2 A9E9 LongMul A867 DIBadMount (0) LoWord A86B DIFormat (6) MapPoly A8FC DILoad (2) MapPt A8F9 DIUnload (4) MapRect A8FA DNerify (8) MapRgn A8FB DIZ.ero (10) MaxMem AllD Pack3 A9EA MenuKey A93E SFGetFile (2) MenuSelect A93D SFPGetFile (4) Modal Dialog A991 SFPPutFile (3) MoreMasters A036 SFPutFile (1) MountVol AOOF Pack4 A9EB PBMountVol Pack5 A9EC Move A894 Pack6 A9ED MoveControl A959 IUDatePString (14) MovePortTo A877 IUDateString (0) MoveTo A893 IUGetlntl (6) MoveWindow A91B IUMagIDString (12) Munger A9EO IUMagString (10) NewControl A954 IVMetric (4) NewDialog A97D IUSetlntl (8) NewHandle Al22 IUTimePString (16) NewMenu A931 IUTimeString (2) NewPtr AllE Pack7 A9EE NewRgn A8D8 NumToString (0) NewString A906 StringToNum (1) II/-218 System Traps System Traps Name Trap word Name Trap word PackBits A8CF ScrollRect A8EF PaintArc A8BF Secs2Date A9C6 PaintBehind A90D SectRect A8AA PaintOne A90C SectRgn A8E4 PaintOval A8B8 SelectWindow A91F PaintPoly A8C7 SeIIText A97E PaintRect A8A2 SendBehind A921 PaintRgn A8D3 SetAppBase A057 PaintRoundRect A8Bl SetApplBase ParamText A98B SetA ppl Limit A02D PenMode A89C SetClip A879 PenNonnal A89E SetCRefCon A95B PenPat A89D SetCTitle A95F PenSize A89B SetCtlAction A96B PicComment A8F2 SetCtIValue A963 PinRect A94E SetCursor A851 Plotlcon A94B SetDateTime A03A PortSize A876 SetDitem A98E PostEvent A02F SetEmptyRgn A8DD Pt2Rect A8AC SetEOF A012 PtlnRect A8AD PBSetEOF PtlnRgn A8E8 SetFilelnfo AOOD PtrAndHand A9EF PBSetFinfo PtrToHand A9E3 SetFiILock A041 PtrToXHand A9E2 PBSetFLock PtrZone A148 SetFiIType A043 PtToAngle A8C3 PBSetFVers PurgeMem A04D SetFontLock A903 PutScrap A9FE SetFPos A044 Random A861 PBSetFPos RDrvrlnstall A04F SetGrowZone A04B (internal use only) SetHandleSize A024 Read A002 Setltem A947 PB Read SetIText A98F ReadDateTime A039 Setltmlcon A940 Real Font A902 Setltemlcon ReallocHandle A027 SetltmMark A944 RecoverHandle A128 SetltemMark RectlnRgn A8E9 SetltmStyle A942 RectRgn A8DF SetltemStyle ReleaseResource A9A3 SetMaxCtl A965 Rename AOOB SetCtlMax PB Rename SetMenuBar A93C ResError A9AF SetMFlash A94A ResrvMem A040 SetMenuFlash RmveResource A9AD SetMinCtl A964 RsrcZonelnit A996 SetCtlMin RstFilLock A042 SetOrigin A878 PBRstFLock SetPBits A875 SaveOld A90E SetPortBits ScalePt A8F8 SetPenState A899 System Traps III-219 Inside Macintosh Name Trap word Name Trap word SetPort A873 SubPt A87F SetPt A880 Sys Beep A9C8 SetPtrSize A020 SysEdit A9C2 SetRecRgn A8DE SystemEdit SetRectRgn SysError A9C9 SetRect A8A7 SystemClick A9B3 SetResAttrs A9A7 SystemEvent A9B2 SetResFileAttrs A9F7 SystemMenu A9B5 SetReslnfo A9A9 SystemTask A9B4 SetResLoad A99B TEActivate A9D8 SetResPurge A993 TECalText A9DO SetStdProcs A8EA TEClick A9D4 SetString A907 TECopy A9D5 SetTrapAddress A047 TECut A9D6 SetVol A015 TEDeactivate A9D9 PBSetVol TEDelete A9D7 SetWindowPic A92E TEDispose A9CD SetWRefCon A918 TEGetText A9CB SetWTitle A91A TEidle A9DA SetZone AOlB TEinit A9CC ShieldCursor A855 TEinsert A9DE ShowControl A957 TEKey A9DC ShowCursor A853 TENew A9D2 Show Hide A908 TEPaste A9DB ShowPen A897 TEScroll A9DD ShowWindow A915 TESetJust A9DF SizeControl A95C TESetSelect A9Dl SizeRsrc A9A5 TESetText A9CF SizeResource TestControl A966 SizeWindow A91D TEUpdate A9D3 SlopeFromAngle A8BC TextBox A9CE SpaceExtra A88E TextFace A888 Status A005 TextFont A887 PB Status TextMode A889 StdArc A8BD TextSize A88A StdBits A8EB TextWidth A886 StdComment A8Fl TickCount A975 StdGetPic A8EE TrackControl A968 StdLine A890 TrackGoAway A91E StdOval A8B6 UnionRect A8AB StdPoly A8C5 UnionRgn A8E5 Std.PutPic A8FO UniquelD A9Cl StdRect A8AO UnloadSeg A9Fl StdRgn A8Dl UnlodeScrap A9FA StdRRect A8AF UnloadScrap StdText A882 UnmountVol AOOE StdTxMeas A8ED PB UnmountVol StillDown A973 UnpackBits ABDO StopAlert A986 UpdateResFile A999 StringWidth A88C UprString A054 StuffHex A866 UseResFile A998 III-220 System Traps System Traps Name Trap word Name Trap word ValidRect A92A Write A003 ValidRgn A929 PBWrite Vlnstall A033 WriteParam A038 VRemove A034 W riteResource A9BO WaitMouseUp A977 XorRgn A8E7 ZeroScrap A9FC Trap word Name Trap word Name AOOO Open A014 GetVol PB Open PBGetVol AOOl Close A015 SetVol PB Close PB SetVol A002 Read A016 InitQueue PBRead A017 Eject A003 Write PB Eject PB Write A018 GetFPos A004 Control PBGetFPos PBControl A019 InitZone A005 Status Al1A GetZone PB Status AOlB SetZone A006 KillIO AOIC FreeMem PBKillIO AIID MaxMem A007 GetVollnfo A11E NewPtr PBGetVInfo AOIF DisposPtr A008 Create A020 SetPtrSize PBCreate A021 GetPtrSize A009 Delete A122 NewHandle PB Delete A023 DisposHandle AOOA OpenRF A024 SetHandleSize PBOpenRF A025 GetHandleSize AOOB Rename A126 HandleZone PB Rename A027 ReallocHandle AOOC GetFilelnfo Al28 RecoverHandle PBGetlnfo A029 HLock AOOD SetFilelnfo A02A HUnlock PBSetFinfo A02B Empty Handle AOOE UnmountVol A02C InitApplZone PB UnmountVol A02D SetApplLirnit AOOF MountVol A02E BlockMove PBMountVol A02F PostEvent AOIO Allocate A030 OSEventAvail PB Allocate A031 GetOSEvent AOl 1 GetEOF A032 FlushEvents PBGetEOF A033 Vlnstall A012 SetEOF A034 VRemove PBSetEOF A035 Offline A013 FlushVol PBOffline PBFlushVol A036 MoreMasters System Traps I-221 Inside Macintosh Trap word Name Trap word Name A038 WriteParam A861 Random A039 ReadDateTime A862 ForeColor A03A SetDateTime A863 BackColor A03B Delay A864 ColorBit A03C CmpString A865 GetPixel Equal String A866 StuffHex A03D Drvrlnstall A867 LongMul (internal use only) A868 FixMul A03E DrvrRemove A869 FixRatio (internal use only) A86A HiWord A03F InitUtil A86B LoWord A040 ResrvMem A86C FixRound A041 SetFilLock A86D InitPort PBSetFLock A86E InitGraf A042 RstFilLock A86F OpenPort PBRstFLock A870 LocalToGlobal A043 SetFilType A871 GlobalToLocal PBSetFVers A872 GrafDevice A044 SetFPos A873 SetPort PBSetFPos A874 GetPort A045 FlushFile A875 SetPBits PBFlushFile SetPortBits A146 GetTrapAddress A876 PortSize A047 SetTrapAddress A877 MovePortTo A148 PtrZone A878 SetOrigin A049 HPurge A879 SetClip A04A HNoPurge A87A GetClip A04B SetGrowZone A87B ClipRect A04C CompactMem A87C BackPat A04D PurgeMem A87D ClosePort A04E AddDrive A87E AddPt (internal use only) A87F SubPt A04F RDrvrlnstall A880 SetPt (internal use only) A881 EqualPt A850 InitCursor A882 StdText A851 SetCursor A883 DrawChar A852 HideCursor A884 DrawString A853 ShowCursor A885 DrawText A054 UprString A886 TextWidth A855 ShieldCursor A887 TextFont A856 ObscureCursor A888 TextFace A057 SetAppBase A889 TextMode SetApplBase A88A TextSize A858 BitAnd A88B GetFontlnfo A859 BitXor A88C StringWidth A85A BitNot A88D CharWidth A85B BitOr A88E SpaceExtra A85C BitShift A890 StdLine A85D BitTst A891 LineTo A85E BitSet A892 Line A85F BitClr A893 MoveTo III-222 System Traps System Traps Trap word Name Trap word Name A894 Move A8C8 ErasePoly A896 HidePen A8C9 InvertPoly A897 Show Pen A8CA Fill Poly A898 GetPenState A8CB OpenPoly A899 SetPenState A8CC ClosePgon A89A GetPen ClosePoly A89B PenSize A8CD KillPoly A89C PenMode A8CE OffsetPoly A89D PenPat A8CF PackBits A89E PenNormal A8DO UnpackBits A8AO StdRect A8Dl StdRgn A8Al FrameRect A8D2 FrameRgn A8A2 PaintRect A8D3 PaintRgn A8A3 EraseRect A8D4 EraseRgn A8A4 InverRect A8D5 InverRgn InvertRect InvertRgn A8A5 FillRect A8D6 FillRgn A8A6 EqualRect A8D8 NewRgn A8A7 SetRect A8D9 DisposRgn A8A8 OffsetRect DisposeRgn A8A9 InsetRect A8DA OpenRgn A8AA SectRect A8DB CloseRgn A8AB UnionRect A8DC CopyRgn A8AC Pt2Rect A8DD SetEmptyRgn ASAD PtinRect A8DE SetRecRgn A8AE EmptyRect A8DF SetRectRgn A8AF StdRRect RectRgn A8BO FrameRoundRect A8EO OfsetRgn A8Bl PaintRoundRect OffsetRgn A8B2 EraseRoundRect A8El InsetRgn A8B3 InverRoundRect A8E2 EmptyRgn InvertRoundRect A8E3 EqualRgn A8B4 FillRoundRect A8E4 SectRgn A8B6 StdOval A8E5 UnionRgn A8B7 FrameOval A8E6 DiffRgn A8B8 PaintOval A8E7 XorRgn A8B9 EraseOval A8E8 PtlnRgn A8BA InvertOval A8E9 RectlnRgn A8BB FillOval A8EA SetStdProcs A8BC SlopeFromAngle A8EB StdBits A8BD StdArc A8EC Copy Bits A8BE FrameArc A8ED StdTxMeas A8BF PaintArc A8EE StdGetPic A8CO EraseArc A8EF ScrollRect A8Cl InvertArc A8FO StdPutPic A8C2 FillArc A8Fl StdComment A8C3 PtToAngle A8F2 PicComment A8C4 AngleFromSlope A8F3 OpenPicture A8C5 StdPoly A8F4 ClosePicture A8C6 FramePoly A8F5 KillPicture A8C7 PaintPoly A8F6 DrawPicture System Traps lll-223 Inside Macintosh Trap word Name Trap word Name A8F8 SealePt A929 ValidRgn A8F9 MapPt A92A ValidReet A8FA MapReet A92B GrowWindow A8FB MapRgn A92C FindWindow A8FC MapPoly A92D CloseWindow A8FE InitFonts A92E SetWindowPie A8FF GetFName A92F GetWindowPie GetFontName A930 InitMenus A900 GetFNum A931 NewMenu A901 FMSwapFont A932 DisposMenu A902 RealFont DisposeMenu A903 SetFontLoek A933 AppendMenu A904 DrawGrowlcon A934 ClearMenuBar A905 Drag Gray Rgn A935 InsertMenu A906 NewString A936 DeleteMenu A907 SetString A937 DrawMenuBar A908 Show Hide A938 HiliteMenu A909 CaleVis A939 EnableItem A90A CaleVBehind A93A Disableltem CaleVisBehind A93B GetMenuBar A90B ClipAbove A93C SetMenuBar A90C PaintOne A93D MenuSeleet A90D PaintBehind A93E MenuKey A90E SaveOld A93F Getltmleon A90F DrawNew Getltemlcon A910 GetWMgrPort A940 Setltmleon A911 CheckUpdate Setltemlcon A912 InitWindows A941 GetltmStyle A913 NewWindow GetltemStyle A914 DisposWindow A942 SetltrnStyle DisposeWindow SetltemStyle A915 ShowWindow A943 GetltrnMark A916 HideWindow GetltemMark A917 GetWRefCon A944 SetltrnMark A918 SetWRefCon SetltemMark A919 GetWfitle A945 Cheekltem A91A SetWfitle A946 Getitern A91B MoveWindow A947 Setltem A91C HiliteWindow A948 CaleMenuSize A91D SizeWindow A949 GetMHandle A91E TraekGoAway A94A Set.MFlash A91F SeleetWindow SetMenuFlash A920 BringToFront A94B Plotleon A921 SendBehind A94C FlashMenuBar A922 BeginUpdate A94D AddResMenu A923 EndUpdate A94E PinReet A924 FrontWindow A94F DeltaPoint A925 DragWindow A950 CountMltems A926 DragTheRgn A951 InsertResMenu A927 InvalRgn A954 NewControl A928 InvalRect III-224 System Traps System Traps Trap word Name Tr ap word Name A955 DisposControl A986 StopAlert DisposeControl A987 NoteAlert A956 KillControls A988 CautionAlert A957 ShowControl A989 CouldAlert A958 HideControl A98A FreeAlert A959 MoveControl A98B ParamText A95A GetCRefCon A98C ErrorSound A95B SetCRefCon A98D GetDitem A95C SizeControl A98E SetDitem A95D HiliteControl A98F SetIText A95E GetCTitle A990 GetlText A95F SetCTitle A991 Modal Dialog A960 GetCtlValue A992 DetachResource A961 GetMinCtl A993 SetResPurge GetCtlMin A994 CurResFile A962 GetMaxCtl A995 InitResources GetCtlMax A996 RsrcZonelnit A963 SetCtlValue A997 OpenResFile A964 SetMinCtl A998 UseResFile SetCtlMin A999 UpdateResFile A965 SetMaxCtl A99A C loseResFile SetCtlMax A99B SetResLoad A966 TestControl A99C CountResources A967 DragControl A99D GetlndResource A968 TrackControl A99E CountTypes A969 DrawControls A99F GetlndType A96A GetCtlAction A9AO GetResource A96B SetCtlAction A9Al GetNamedResource A96C FindControl A9A2 LoadResource A96E Dequeue A9A3 ReleaseResource A96F Enqueue A9A4 HomeResFile A970 GetNextEvent A9A5 SizeRs re A97 1 EventAvail SizeResource A972 GetMouse A9A6 GetResAttrs A973 Still Down A9A7 SetResAttrs A974 Button A9A8 GetReslnfo A975 TickCount A9A9 SetReslnfo A976 GetKeys A9AA ChangedResource A977 WaitMouseUp A9AB AddResource A979 CouldDialog A9AD RmveResource A97A FreeDialog A9AF ResError A97B InitDialogs A9BO W riteResource A97C GetNewDialog A9Bl CreateResFile A97D NewDialog A9B2 SystemEvent A97E SelIText A9B3 SystemClick A97F IsDialogEvent A9B4 SystemTask A980 DialogSelect A9B5 SystemMenu A981 DrawDialog A9B6 OpenDeskAcc A982 CloseDialog A9B7 CloseDeskAcc A983 DisposDialog A9B8 GetPattem A985 Alert A9B9 GetCursor System Traps 111-225 Inside Macintosh Trap word Name Trap word Name A9BA GetString A9E9 Pack2 A9BB Ge ticon DIBadMount (0) A9BC GetPicture DILoad (2) A9BD GetNewWindow DIUnload (4) A9BE GetNewControl DIFormat (6) A9BF GetRMenu DIVerify (8) GetMenu DIZero (10) A9CO GetNewMBar A9EA Pack3 A9Cl UniqueID SFPutFile (1) A9C2 SysEdit SFGetFile (2) SystemEdit SFPPutFile (3) A9C6 Secs2Date SFPGetFile (4) A9C7 Date2Secs A9EB Pack4 A9C8 SysBeep (synonym: FP68K) A9C9 Sys Error A9EC Pack5 A9CB TEGetText (synonym: Elems68K) A9CC TEinit A9ED Pack6 A9CD TEDispose IUDateString (0) A9CE TextBox IUTimeStri ng (2) A9CF TESetText IUMetric (4) A9DO TECalText IUDGetlntl (6) A9Dl TESetSelect IUSetlntl (8) A9D2 TENew IUMagString (10) A9D3 TEUpdate IUMagIDString (12) A9D4 TEClick IUDatePString (14) A9D5 TECopy IUTimePString ( 16) A9D6 TECut A9EE Pack7 A9D7 TEDelete NumToString (0) A9D8 TEActivate StringToNum (I) A9D9 TEDeactivate A9EF PtrAndHand A9DA TEIdie A9FO LoadSeg A9DB TEPaste A9Fl UnloadSeg A9DC TEKey A9F2 Launch A9DD TEScroll A9F3 Chain A9DE TEinsert A9F4 ExitToShell A9DF TESetJust A9F5 GetAppPanns A9EO Munger A9F6 GetResFileAttrs A9El HandToHand A9F7 SetResFileAttrs A9E2 PtrToXHand A9F9 InfoScrap A9E3 PtrToHand A9FA UnlodeScrap A9E4 HandAndHand UnloadScrap A9E5 InitPack A9FB LodeScrap A9E6 InitAllPacks Load Scrap A9E7 PackO A9FC Zero Scrap (reserved for future use) A9FD GetScrap A9E8 Pack! A9FE PutScrap (reserved for future use) ///-226 System Traps APPENDIX D: GLOBAL VARIABLES This appendix gives an alphabetical list of all system global variables described in Inside Macintosh, along with their locations in memory. Name Location Contents ABusVars $208 Pointer to AppleTalk variables A Count $A9A Stage number (0 through 3) of last alert (word) AN umber $A98 Resource ID of last alert (word) ApFontID $984 Font number of application font (word) ApplLimit $ 130 Application heap limit ApplScratch $A78 12-byte scratch area reserved for use by applications ApplZone $2AA Address of application heap zone AppParmHandle $AEC Handle to Finder information BufPtr $10C Address of end of jump table BufrgDate $304 File tags buffer: date and time of last modification (long) BuITgFBkNum $302 File tags buffer: logical block number (word) BuITgFFlg $300 File tags buffer: flags (word: bit l = l if resource fork) BufrgFNum $2FC File tags buffer: file number (long) CaretTime $2F4 Caret-blink interval in ticks (long) CrsrThresh $8EC Mouse-scaling threshold (word) CurActivate $A64 Pointer to window to receive activate event CurApName $910 Name of current application (length byte followed by up to 31 characters) CurApRefNum $900 Reference number of current application's resource file (word) CurDeactive $A68 Pointer to window to receive deactivate event CurJTOffset $934 Offset to jump table from location pointed to by A5 (word) CurMap $A5A Reference number of current resource file (word) CurPageOption $936 Sound/screen buffer configuration passed to Chain or Launch (word) CurPitch $280 Value of count in square-wave synthesizer buffer (word) CurrentA5 $904 Address of boundary between application globals and application parameters CurStackBase $908 Address of base of stack; start of application globals DABeeper $A9C Address of current sound procedure DAStrings $AAO Handles to ParamText strings (16 bytes) Global Variables /II-227 Inside Macintosh Name Location Contents DefltStack $322 Default space allotment for stack (long) DefVCBPtr $352 Pointer to default volume control block DeskHook $A6C Address of procedure for painting desktop or responding to clicks on desktop DeskPattern $A3C Pattern with which desktop is painted (8 bytes) DlgFont $APA Font number for dialogs and alerts (word) DoubleTime $2FO Double-click interval in ticks (long) DragHook $9F6 Address of procedure to execute during TrackGoAway , DragWindow, GrowWindow, DragGrayRgn, TrackControl, and DragControl DragPattem $A34 Pattern of dragged region's outline (8 bytes) DrvQHdr $308 Drive queue header (10 bytes) DSAlertRect $3F8 Rectangle enclosing system error alert (8 bytes) DSAlertTab $2BA Pointer to system error alert table in use DSErrCode $APO Current system error ID (word) EventQueue $14A Event queue header (10 bytes) ExtStsDT $2BE External/status interrupt vector table (16 bytes) FCBSPtr $34E Pointer to file-control-block buffer FinderName $2EO Name of the Finder (length byte followed by up to 15 characters) FScaleDisable $A63 Nonzero to disable font scaling (byte) FSQHdr $360 File I/O queue header ( 10 bytes) GhostWindow $A84 Pointer to window never to be considered frontmost GrayRgn $9EE Handle to region drawn as desktop GZRootHnd $328 Handle to relocatable block not to be moved by grow zone function HeapEnd $114 Address of end of application heap zone JFetch $8F4 Jump vector for Fetch function TIODone $8FC Jump vector for IODone function JournalFlag $8DE Journaling mode (word) JoumalRef $8E8 Reference number of journaling device driver (word) JStash $8F8 Jump vector for Stash function Key RepThresh $190 Auto-key rate (word) KeyThresh $18E Auto-key threshold (word) Lo3Bytes $31A $00FFFFFF LvllDT $192 Level-I secondary interrupt vector table (32 bytes) III-228 Global Variables Global. Variables Name Location Contents Lvl2DT $1B2 ' Level-2 secondary interrupt vector table (32 bytes) MBarEnable $A20 Unique menu ID for active desk accessory, when menu bar belongs to the accessory (word) MBarHook $A2C Address of routine called by MenuSelect before menu is drawn MemTop $108 Address of end of RAM (on Macintosh XL, end of RAM available to applications) MenuFlash $A24 Count for duration of menu item blinking (word) MenuHook $A30 Address of routine called during MenuSelect MenuList $A1C Handle to current menu list MinStack $31E Minimum space allotment for stack (long) MinusOne $A06 $FFFFFFFF OldContent $9EA Handle to saved content region OldStructure $9E6 Handle to saved structure region OneOne $A02 $00010001 PaintWhite $9DC Flag for whether to paint window white before update event (word) PortBUse $291 Current availability of serial port B (byte) PrintErr $944 Result code from last Printing Manager routine (word) RAMBase $2B2 Trap dispatch table's base address for routines in RAM Res Err $A60 Current value of ResError (word) ResErrProc $AF2 Address of resource error procedure ResLoad $ASE Current SetResLoad state (word) ResumeProc $A8C Address of resume procedure RndSeed $156 Random number seed (long) ROMBase $2AE Base address of ROM RO:MFontO $980 Handle to font record for system font SaveUpdate $9DA Flag for whether to generate update events (word) SaveVisRgn $9F2 Handle to saved visRgn SCCRd $108 sec read base address SCCWr $1DC sec write base address ScrapCount $968 Count changed by ZeroScrap (word) ScrapHandle $964 Handle to desk scrap in memory ScrapName $96C Pointer to scrap file name (preceded by length byte) ScrapSize $960 Size in bytes of desk scrap (long) ScrapState $96A Tells where desk scrap is (word) Global Variables III-229 Inside Macintosh Name Location Contents Scratch8 $9FA 8-byte scratch area Scratch20 $1E4 20-byte scratch area ScrDmpEnb $2F8 0 if GetNextEvent shouldn't process Command-Shift-number combinations (byte) ScrHRes $104 Pixels per inch horizontally (word) ScmBase $824 Address of main screen buffer ScrVRes $102 Pixels per inch vertically (word) SdVolume $260 Current speaker volume (byte: low-order three bits only) SEvtEnb $15C 0 if SystemEvent should return FALSE (byte) SFSaveDisk $214 Negative of volume reference number used by Standard File Package (word) SoundBase $266 Pointer to free-form synthesizer buffer Sound.Level $27F Amplitude in 740-byte buffer (byte) SoundPtr $262 Pointer to four-tone record SPAlarm $200 Alarm setting (long) SPATalkA $1F9 AppleTalk node ID hint for modem port (byte) SPATalkB $1FA AppleTalk node ID hint for printer port (byte) SPClikCaret $209 Double-click and caret-blink times (byte) SPConfig $1FB Use types for serial ports (byte) SPFont $204 Application font number minus 1 (word) SPKbd $206 Auto-key threshold and rate (byte) SPMisc2 $20B Mouse scaling, system startup disk, menu blink (byte) SPPortA $1FC Modem port configuration (word) SPPortB $1FE Printer port configuration (word) SPPrint $207 Printer connection (byte) SPValid $1F8 Validity status (byte) SPVolCtl $208 Speaker volume setting in parameter RAM (byte) SysEvtMask $144 System event mask (word) SysMap $A58 Reference number of system resource file (word) SysMapHndl $A54 Handle to map of system resource file SysParam $1F8 Low-memory copy of parameter RAM (20 bytes) SysResName $ADS Name of system resource file (length byte followed by up to 19 characters) SysZone $2A6 Address of system heap zone TEDoText $A70 Address of TextEdit multi-purpose routine III-230 Global Variables Global Variables Name Location Contents TERecal $A74 Address of routine to recalculate line starts for TextEdit TEScrpHandle $AB4 Handle to TextEdit scrap TEScrpLength $ABO Size in bytes ofTextEdit scrap (long) TheMenu $A26 Menu ID of currently highlighted menu (word) TheZone $118 Address of current heap zone Ticks $16A Current number of ticks since system startup (long) Time $20C Seconds since midnight, January 1, 1904 (long) ToExtFS $3F2 Pointer to external file system ToolScratch $9CE 8-byte scratch area TopMapHndl $A50 Handle to resource map of most recently opened resource file UTableBase $11C Base address of unit table VBLQueue $160 Vertical retrace queue header (10 bytes) VCBQHdr $356 Volume-control-block queue header (10 bytes) VIA $IDA VIA base address WindowList $9D6 Pointer to first window in window list; 0 if using events but not windows WMgrPort $9DE Pointer to Window Manager port Global Variables l/l-231 Inside Macintosh 111-232 GLOSSARY access path: A description of the route that the File Manager follows to access a file; created when a file is opened. access path buffer: Memory used by the File Manager to transfer data between an application and a file. action procedure: A procedure, used by the Control Manager function TrackControl, that defines an action to be performed repeatedly for as long as the mouse button is held down. activate event: An event generated by the Window Manager when a window changes from active to inactive or vice versa. active control: A control that will respond to the user's actions with the mouse. active window: The frontmost window on the desktop. address mark: In a sector, information that's used internally by the Disk Driver, including information it uses to determine the position of the sector on the disk. ALAP: See AppleTalk Link Access Protocol. ALAP frame: A packet of data transmitted and received by ALAP. ALAP protocol type: An identifier used to match particular kinds of packets with a particular protocol handler. alert: A warning or report of an error, in the form of an alert box, sound from the Macintosh's speaker, or both. alert box: A box that appears on the screen to give a warning or report an error during a Macintosh application. alert template: A resource that contains information from which the Dialog Manager can create an alert. alert window: The window in which an alert box is displayed. alias: A different name for the same entity. allocate: To reserve an area of memory for use. allocation block: Volume space composed of an integral number of logical blocks. amplitude: The maximum vertical distance of a periodic wave from the horizontal line about which the wave oscillates. AppleTalk address: A socket's number and its node ID number. Glossary 111-233 Inside Macintosh AppleTalk Link Access Protocol (ALAP): The lowest-level protocol in the AppleTalk architecture, managing node-to-node delivery of frames on a single AppleTalk network. AppleTalk Manager: An interface to a pair of RAM device drivers that enable programs to send and receive information via an AppleTalk network. AppleTalk Transaction Protocol (ATP): An AppleTalk protocol that's a DDP client. It allows one ATP client to request another ATP client to perform some activity and report the activity's result as a response to the requesting socket with guaranteed delivery. application font: The font your application will use unless you specify otherwise-Geneva, by default. application heap: The portion of the heap available to the running application program and the Toolbox. application heap limit: The boundary between the space available for the application heap and the space available for the stack. application heap zone: The heap zone initially provided by the Memory Manager for use by the application program and the Toolbox; initially equivalent to the application heap, but may be subdivided into two or more independent heap zones. application parameters: Thirty-two bytes of memory, located above the application globals, reserved for system use. The first application parameter is the address of the first QuickDraw global variable. application space: Memory that's available for dynamic allocation by applications. application window: A window created as the result of something done by the application, either directly or indirectly (as through the Dialog Manager). ascent: The vertical distance from a font's base line to its ascent line. ascent line: A horizontal line that coincides with the tops of the tallest characters in a font. asynchronous communication: A method of data transmission where the receiving and sending devices don't share a common timer, and no timing data is transmitted. asynchronous execution: After calling a routine asynchronously, an application is free to perform other tasks until the routine is completed. at-least-once transaction: An ATP transaction in which the requested operation is performed at least once, and possibly several times. ATP: See AppleTalk Transaction Protocol. auto-key event: An event generated repeatedly when the user presses and holds down a character key on the keyboard or keypad. auto-key rate: The rate at which a character key repeats after it's begun to do so. ///-234 Glossary Glossary auto-key threshold: The length of time a character key must be held down before it begins to repeat. background procedure: A procedure passed to the Printing Manager to be run during idle times in the printing process. base line: A horizontal line that coincides with the bottom of each character in a font, excluding descenders (such as the tail of a "p"). baud rate: The measure of the total number of bits sent over a transmission line per second. Binary-Decimal Conversion Package: A Macintosh package for converting integers to decimal strings and vice versa. bit image: A collection of bits in memory that have a rectilinear representation. The screen is a visible bit image. bit map: A set of bits that represent the position and state of a corresponding set of items; in QuickDraw, a pointer to a bit image, the row width of that image, and its boundary rectangle. block: A group regarded as a unit; usually refers to data or memory in which data is stored. See allocation block and memory block. block contents: The area that's available for use in a memory block. block device: A device that reads and writes blocks of bytes at a time. It can read or write any accessible block on demand. block header: The internal "housekeeping" information maintained by the Memory Manager at the beginning of each block in a heap zone. block map: Same as volume allocation block map. boundary rectangle: A rectangle, defined as part of a QuickDraw bit map, that encloses the active area of the bit image and imposes a coordinate system on it. Its top left comer is always aligned around the first bit in the bit image. break: The condition resulting when a device maintains its transmission line in the space state for at least one frame. bridge: An intelligent link between two or more AppleTalk networks. broadcast service: An ALAP service in which a frame is sent to all nodes on an AppleTaJk network. bundle: A resource that maps local IDs of resources to their actual resource IDs; used to provide mappings for file references and icon lists needed by the Finder. button: A standard Macintosh control that causes some immediate or continuous action when clicked or pressed with the mouse. See also radio button. Glossary 111-235 Inside Macintosh caret: A generic term meaning a symbol that indicates where something should be inserted in text. The specific symbol used is a vertical bar ( I ). caret-blink time: The interval between blinks of the caret that marks an insertion point character code: An integer representing the character that a key or combination of keys on the keyboard or keypad stands for. character device: A device that reads or writes a stream of characters, one at a time. It can neither skip characters nor go back to a previous character. character image: An arrangement of bits that defines a character in a font. character key: A key that generates a keyboard event when pressed; any key except Shift, Caps Lock, Command, or Option. character offset: The horizontal separation between a character rectangle and a font rectangle. character origin: The point on a base line used as a reference location for drawing a character. character position: An index into an array containing text, starting at 0 for the first character. character rectangle: A rectangle enclosing an entire character image. Its sides are defined by the image width and the font height. character style: A set of stylistic variations, such as bold, italic, and underline. The empty set indicates plain text (no stylistic variations). character width: The distance to move the pen from one character's origin to the next character's origin. check box: A standard Macintosh control that displays a setting, either checked (on) or unchecked (oft). Clicking inside a check box reverses its setting. clipping: Limiting drawing to within the bounds of a particular area. clipping region: Same as clipRgn. clipRgn: The region to which an application limits drawing in a grafPort. clock chip: A special chip in which are stored parameter RAM and the current setting for the date and time. This chip is powered by a battery when the system is off, thus preserving the information. close routine: The part of a device driver's code that implements Device Manager Close calls. closed driver: A device driver that cannot be read from or written to. closed file: A file without an access path. Closed files cannot be read from or written to. compaction: The process of moving allocated blocks within a heap zone in order to collect the free space into a single block. III-236 Glossary Glossary completion routine: Any application-defined code to be executed when an asynchronous call to a routine is completed. content region: The area of a window that the application draws in. control: An object in a window on the Macintosh screen with which the user, using the mouse, can cause instant action with visible results or change settings to modify a future action. control definition function: A function called by the Control Manager when it needs to perform type-dependent operations on a particular type of control, such as drawing the control. control definition ID: A number passed to control-creation routines to indicate the type of control. It consists of the control definition function's resource ID and a variation code. control information: Information transmitted by an application to a device driver. It may select modes of operation, start or stop processes, enable buffers, choose protocols, and so on. control list: A list of all the controls associated with a given window. Control Manager: The part of the Toolbox that provides routines for creating and manipulating controls (such as buttons, check boxes, and scroll bars). control record: The internal representation of a control, where the Control Manager stores all the information it needs for its operations on that control. control routine: The part of a device driver's code that implements Device Manager Control and KilllO calls. control template: A resource that contains information from which the Control Manager can create a control. coordinate plane: A two-dimensional grid. In QuickDraw, the grid coordinates are integers ranging from -32767 to 32767, and all grid lines are infinitely thin. current heap zone: The heap zone currently under attention, to which most Memory Manager operations implicitly apply. current resource file: The last resource file opened, unless you specify otherwise with a Resource Manager routine. cursor: A 16-by-16 bit image that appears on the screen and is controlled by the mouse; called the "pointer'' in Macintosh user manuals. cursor level: A value, initialized by InitCursor, that keeps track of the number of times the cursor has been hidden. data bits: Data communications bits that encode transmitted characters. data buffer: Heap space containing information to be written to a file or device driver from an application, or read from a file or device driver to an application. data fork: The part of a file that contains data accessed via the File Manager. Glossary III-237 Inside Macintosh data mark: In a sector, information that primarily contains data from an application. datagram: A packet of data transmitted by DDP. Datagram Delivery Protocol (DDP): An AppleTalk protocol that's an ALAP client, managing socket-to-socket delivery of datagrams over AppleTalk internets. date/time record: An alternate representation of the date and time (which is stored on the clock chip in seconds since midnight, January 1, 1904). DDP: See Datagram Delivery Protocol. default button: In an alert box or modal dialog, the button whose effect will occur if the user presses Return or Enter. In an alert box, it's boldly outlined; in a modal dialog, it's boldly outlined or the OK button. default volume: A volume that will receive I/O during a File Manager routine call, whenever no other volume is specified. dereference: To refer to a block by its master pointer instead of its handle. descent: The vertical distance from a font's base line to its descent line. descent line: A horizontal line that coincides with the bottoms of the characters in a font that extend furthest below the base line. desk accessory: A "mini-application", implemented as a device driver, that can be run at the same time as a Macintosh application. Desk Manager: The part of the Toolbox that supports the use of desk accessories from an application. desk scrap: The place where data is stored when it's cut (or copied) and pasted among applications and desk accessories. desktop: The screen as a surface for doing work on the Macintosh. Desktop file: A resource file in which the Finder stores the version data, bundle, icons, and file references for each application on the volume. destination rectangle: In TextEdit, the rectangle in which the text is drawn. device: A part of the Macintosh, or a piece of external equipment, that can transfer information into or out of the Macintosh. device control entry: A 40-byte relocatable block of heap space that tells the Device Manager the location of a driver's routines, the location of a driver's 110 queue, and other information. device driver: A program that controls the exchange of information between an application and a device. device driver event: An event generated by one of the Macintosh's device drivers. 111-238 Glossary Glossary Device Manager: The part of the Operating System that supports device I/O. dial: A control with a moving indicator that displays a quantitative setting or value. Depending on the type of dial, the user may be able to change the setting by dragging the indicator with the mouse. dialog: Same as dialog box. dialog box: A box that a Macintosh application displays to request information it needs to complete a command, or to report that it's waiting for a process to complete. Dialog Manager: The part of the Toolbox that provides routines for implementing dialogs and alerts. dialog record: The internal representation of a dialog, where the Dialog Manager stores all the information it needs for its operations on that dialog. dialog template: A resource that contains information from which the Dialog Manager can create a dialog. dialog window: The window in which a dialog box is displayed. dimmed: Drawn in gray rather than black disabled: A disabled menu item or menu is one that cannot be chosen; the menu item or menu title appears dimmed. A disabled item in a dialog or alert box has no effect when clicked. Disk Driver: The device driver that controls data storage and retrieval on 3 1/2-inch disks. Disk Initialization Package: A Macintosh package for initializing and naming new disks; called by the Standard File Package. disk-inserted event: An event generated when the user inserts a disk in a disk drive or takes any other action that requires a volume to be mounted. display rectangle: A rectangle that determines where an item is displayed within a dialog or alert box. document window: The standard Macintosh window for presenting a document. double-click time: The greatest interval between a mouse-up and mouse-down event that would qualify two mouse clicks as a double-click. draft printing: Printing a document immediately as it's drawn in the printing grafPort. drag region: A region in a window frame. Dragging inside this region moves the window to a new location and makes it the active window unless the Command key was down. drive number: A number used to identify a disk drive. The internal drive is number 1, the external drive is number 2, and any additional drives will have larger numbers. drive queue: A list of disk drives connected to the Macintosh. Glossary IIJ-239 Inside Macintosh driver name: A sequence of up to 255 printing characters used to refer to an open device driver. Driver names always begin with a period (.). driver 1/0 queue: A queue containing the parameter blocks of all UO requests for one device driver. driver reference number: A number from - 1 to -32 that uniquely identifies an individual device driver. edit record: A complete editing environment in TextEdit, which includes the text to be edited, the grafPort and rectangle in which to display the text, the arrangement of the text within the rectangle, and other editing and display information. empty handle: A handle that points to a NIL master pointer, signifying that the underlying relocatable block has been purged. empty shape: A shape that contains no bits, such as one defined by only a single point. end-of-file: See logical end-of-file or physical end-of-file . entity name : An identifier for an entity, of the form object:type@zone. event: A notification to an application of some occurrence that the application may want to respond to. event code: An integer representing a particular type of event. Event Manager: See Toolbox Event Manager or Operating System Event Manager. event mask: A parameter passed to an Event Manager routine to specify which types of events the routine should apply to. event message: A field of an event record containing information specific to the particular type of event. event queue: The Operating System Event Manager's list of pending events. event record: The internal representation of an event, through which your program learns all pertinent information about that event. exactly-once transaction: An ATP transaction in which the requested operation is performed only once. exception: An error or abnormal condition detected by the processor in the course of program execution; includes interrupts and traps. exception vector: One of 64 vectors in low memory that point to the routines that are to get control in the event of an exception. external reference: A reference to a routine or variable defined in a separate compilation or assembly. III-240 Glossary Glossary file: A named, ordered sequence of bytes; a principal means by which data is stored and transmitted on the Macintosh. file control block: A fixed-length data structure, contained in the file-control-block buffer, where information about an access path is stored. file-control-block buffer: A nonrelocatable block in the system heap that contains one file control block for each access path. file directory: The part of a volume that contains descriptions and locations of all the files on the volume. file I/O queue: A queue containing parameter blocks for all 1/0 requests to the File Manager. File Manager: The part of the Operating System that supports file 1/0. file name: A sequence of up to 255 printing characters, excluding colons (:),that identifies a file. file number: A unique number assigned to a file, which the File Manager uses to distinguish it from other files on the volume. A file number specifies the file's entry in a file directory. file reference: A resource that provides the Finder with file and icon information about an application. file tags: Information associated with each logical block, designed to allow reconstruction of files on a volume whose directory or other file-access information has been destroyed. file tags buffer: A location in memory where file tags are read from and written to. file type: A four-character sequence, specified when a file is created, that identifies the type of file. Finder information: Information that the Finder provides to an application upon starting it up, telling it which documents to open or print. fixed-point number : A signed 32-bit quantity containing an integer part in the high-order word and a fractional part in the low-order word. fixed-width font: A font whose characters all have the same width. Floating-Point Arithmetic Package: A Macintosh package that supports extended-precision arithmetic according to IEEE Standard 754. font: The complete set of characters of one typeface. font characterization table: A table of parameters in a device driver that specifies how best to adapt fonts to that device. font height: The vertical distance from a font's ascent line to its descent line. Glossary ///-241 Inside Macintosh Font Manager: The part of the Toolbox that supports the use of various character fonts fo r QuickDraw when it draws text. font number: The number by which you identify a font to QuickDraw or the Font Manager. font record: A data structure that contains all the information describing a font. font rectangle: The smallest rectangle enclosing all the character images in a font, if the images were all superimposed over the same character origin. font size: The size of a font in points; equivalent to the distance between the ascent line of one line of text and the ascent line of the next line of single-spaced text. fork: One of the two parts of a file; see data fork and resource fork. four-tone record: A data structure describing the tones produced by a four-tone synthesizer. four-tone synthesizer: The part of the Sound Driver used to make simple harmonic tones, with up to four "voices" producing sound simultaneously. frame: The time elapsed from the start bit to the last stop bit during serial communication. frame check sequence: A 16-bit value generated by the AppleTalk hardware, used by the receiving node to detect transmission errors. frame header: Information at the beginning of a packet. frame pointer: A pointer to the end of the local variables within a routine's stack frame, held in an address register and manipulated with the LINK and UNLK instructions. frame trailer: Information at the end of an ALAP frame. framed shape: A shape that's drawn outlined and hollow. framing error: The condition resulting when a device doesn't receive a stop bit when expected. free block: A memory block containing space available for allocation. free-form synthesizer: The part of the Sound Driver used to make complex music and speech. frequency: The number of cycles per second (also called hertz) at which a wave oscillates. full-duplex communication: A method of data transmission where two devices transmit data simultaneously. global coordinate system: The coordinate system based on the top left comer of the bit image being at (0,0). go-away region: A region in a window frame. Clicking inside this region of the active window makes the window close or disappear. l//-242 Glossary Glossary grafPort: A complete drawing environment, including such elements as a bit map, a subset of it in which to draw, a character font, patterns for drawing and erasing, and other pen characteristics. grow image: The image pulled around when the user drags inside the grow region; whatever is appropriate to show that the window's size will change. grow region: A window region, usually within the content region, where dragging changes the size of an active window. grow zone function: A function supplied by the application program to help the Memory Manager create free space within a heap zone. handle: A pointer to a master pointer, which designates a relocatable block in the heap by double indirection. hardware overrun error: The condition that occurs when the SCC's buffer becomes full. heap: The area of memory in which space is dynamically allocated and released on demand, using the Memory Manager. heap zone: An area of memory initialized by the Memory Manager for heap allocation, highlight: To display an object on the screen in a distinctive visual way, such as inverting it. horizontal blanking interval: The time between the display of the rightmost pixel on one line and the leftmost pixel on the next line. hotSpot: The point in a cursor that's aligned with the mouse location. icon: A 32-by-32 bit image that graphically represents an object, concept, or message. icon list: A resource consisting of a list of icons. icon number: A digit from 1 to 255 to which the Menu Manager adds 256 to get the resource ID of an icon associated with a menu item. image width: The width of a character image. inactive control : A control that won't respond to the user's actions with the mouse. An inactive control is highlighted in some special way, such as dimmed. inactive window : Any window that isn't the frontmost window on the desktop. indicator: The moving part of a dial that displays its current setting. input driver: A device driver that receives serial data via a serial port and transfers it to an application. insertion point: An empty selection range; the character position where text will be inserted (usually marked with a blinking caret). Glossary III-243 Inside Macintosh interface routine: A routine called from Pascal whose purpose is to trap to a certain Toolbox or Operating System routine. International Utilities Package: A Macintosh package that gives you access to country- dependent information such as the formats for numbers, currency, dates, and times. internet: An interconnected group of AppleTalk networks. internet address: The AppleTalk address and network number of a socket. interrupt: An exception that's signaled to the processor by a device, to notify the processor of a change in condition of the device, such as the completion of an 1/0 request. interrupt handler: A routine that services interrupts. interrupt priority level: A number identifying the importance of the interrupt. It indicates which device is interrupting, and which interrupt handler should be executed. interrupt vector: A pointer to an interrupt handler. invert: To highlight by changing white pixels to black and vice versa. invisible control: A control that's not drawn in its window. invisible window: A window that's not drawn in its plane on the desktop. 1/0 queue: See driver 1/0 queue or file 1/0 queue. 1/0 request: A request for input from or output to a file or device driver; caused by calling a File Manager or Device Manager routine asynchronously. item: In dialog and alert boxes, a control, icon, picture, or piece of text, each displayed inside its own display rectangle. See also menu item. item list: A list of information about all the items in a dialog or alert box. item number: The index, starting from 1, of an item in an item list. IWM: "Integrated Woz Machine"; the custom chip that controls the 3 1/2-inch disk drives. job dialog: A dialog that sets information about one printing job; associated with the Print command. journal code: A code passed by a Toolbox Event Manager routine in its Control call to the journaling device driver, to designate which routine is making the Control call. journaling mechanism: A mechanism that allows you to feed the Toolbox Event Manager events from some source other than the user. jump table: A table that contains one entry for every routine in an application and is the means by which the loading and unloading of segments is implemented. I//-244 Glossary Glossary justification: The horizontal placement of lines of text relative to the edges of the rectangle in which the text is drawn. kern: To draw part of a character so that it overlaps an adjacent character. key code: An integer representing a key on the keyboard or keypad, without reference to the character that the key stands for. key-down event: An event generated when the user presses a character key on the keyboard or keypad. key-up event: An event generated when the user releases a character key on the keyboard or keypad. keyboard configuration: A resource that defines a particular keyboard layout by associating a character code with each key or combination of keys on the keyboard or keypad. keyboard equivalent: The combination of the Command key and another key, used to invoke a menu item from the keyboard. keyboard event: An event generated when the user presses, releases, or holds down a character key on the keyboard or keypad; any key-down, key-up, or auto-key event. leading: The amount of blank vertical space between the descent line of one line of text and the ascent line of the next line of single-spaced text. ligature: A character that combines two letters. list separator: The character that separates numbers, as when a list of numbers is entered by the user. local coordinate system: The coordinate system local to a grafPort, imposed by the boundary rectangle defined in its bit map. local ID: A number that refers to an icon list or file reference in an application's resource file and is mapped to an actual resource ID by a bundle. location table: An array of words (one for each character in a font) that specifies the location of each character's image in the font's bit image. lock: To temporarily prevent a relocatable block from being moved during heap compaction. lock bit: A bit in the master pointer to a relocatable block that indicates whether the block is currently locked. locked file: A file whose data cannot be changed. locked volume: A volume whose data cannot be changed. Volumes can be locked by either a software flag or a hardware setting. logical block: Volume space composed of 512 consecutive bytes of standard information and an additional number of bytes of information specific to the Disk Driver. Glossary III-245 Inside Macintosh logical end-of-file: The position of one byte past the last byte in a file ; equal to the actual number of bytes in the file. logical size: The number of bytes in a memory block's contents. magnitude : The vertical distance between any given point on a wave and the horizontal line about which the wave oscillates. main event loop: In a standard Macintosh application program, a loop that repeatedly calls the Toolbox Event Manager to get events and then responds to them as appropriate. main segment: The segment containing the main program. mark: The position of the next byte in a file that will be read or written. mark state: The state of a transmission line indicating a binary 1. master directory block: Part of the data structure of a volume; contains the volume information and the volume allocation block map. master pointer: A single pointer to a relocatable block, maintained by the Memory Manager and updated whenever the block is moved, purged, or reallocated. All handles to a relocatable block refer to it by double indirection through the master pointer. memory block: An area of contiguous memory within a heap zone. Memory Manager: The part of the Operating System that dynamically allocates and releases memory space in the heap. menu: A list of menu items that appears when the user points to a menu title in the menu bar and presses the mouse button. Dragging through the menu and releasing over an enabled menu item chooses that item. menu bar: The horizontal strip at the top of the Macintosh screen that contains the menu titles of all menus in the menu list. menu definition procedure: A procedure called by the Menu Manager when it needs to perform type-dependent operations on a particular type of menu, such as drawing the menu. menu ID: A number in the menu record that identifies the menu. menu item: A choice in a menu, usually a command to the current application. menu item number: The index, starting from 1, of a menu item in a menu. menu list: A list containing menu handles for all menus in the menu bar, along with information on the position of each menu. Menu Manager: The part of the Toolbox that deals with setting up menus and letting the user choose from them. ///-246 Glossary Glossary menu record: The internal representation of a menu, where the Menu Manager stores all the information it needs for its operations on that menu. menu title: A word or phrase in the menu bar that designates one menu. missing symbol: A character to be drawn in case of a request to draw a character that's missing from a particular font. modal dialog: A dialog that requires the user to respond before doing any other work on the desktop. modeless dialog: A dialog that allows the user to work elsewhere on the desktop before responding. modifier key: A key (Shift, Caps Lock, Option, or Command) that generates no keyboard events of its own, but changes the meaning of other keys or mouse actions. mounted volume: A volume that previously was inserted into a disk drive and had descriptive information read from it by the File Manager. mouse-down event: An event generated when the user presses the mouse button. mouse scaling: A feature that causes the cursor to move twice as far during a mouse stroke than it would have otherwise, provided the change in the cursor's position exceeds the mouse- scaling threshold within one tick after the mouse is moved. mouse-scaling threshold: A number of pixels which, if exceeded by the sum of the horizontal and vertical changes in the cursor position during one tick of mouse movement, causes mouse scaling to occur (if that feature is turned on); normally six pixels. mouse-up event: An event generated when the user releases the mouse button. Name-Binding Protocol (NBP): An AppleTalk protocol that's a DDP client, used to convert entity names to their internet socket addresses. name lookup: An NBP operation that allows clients to obtain the internet addresses of entities from their names. names directory: The union of all name tables in an internet. names information socket: The socket in a node used to implement NBP (always socket number 2). names table: A list of each entity's name and internet address in a node. NBP: See Name-Binding Protocol. NBP tuple: An entity name and an internet address. network event: An event generated by the AppleTalk Manager. network number: An identifier for an AppleTalk network. Glossary III-247 Inside Macintosh network-visible entity: A named socket client on an internet. newline character: Any character, but usually Return (ASCII code $00), that indicates the end of a sequence of bytes. newline mode: A mode of reading data where the end of the data is indicated by a newline character (and not by a specific byte count). node: A device that's attached to and communicates via an AppleTalk network. node ID: A number, dynamically assigned, that identifies a node. nonbreaking space: The character with ASCII code $CA; drawn as a space the same width as a digit, but interpreted as a nonblank character for the purposes of word wraparound and selection. nonrelocatable block: A block whose location in the heap is fixed and can't be moved duri ng heap compaction. null event: An event reported when there are no other events to report. off-line volume: A mounted volume with all but 94 bytes of its descriptive information released. offset/width table: An array of words that specifies the character offsets and character widths of all characters in a font. on-line volume: A mounted volume with its volume buffer and descriptive information contained in memory. open driver: A driver that can be read from and written to. open file: A file with an access path. Open files can be read from and written to. open permission: Information about a file that indicates whether the file can be read from, written to, or both. open routine: The part of a device driver's code that implements Device Manager Open calls. Operating System: The lowest-level software in the Macintosh. It does basic tasks such as 1/0, memory management, and interrupt handling. Operating System Event Manager: The part of the Operating System that reports hardware- related events such as mouse-button presses and keystrokes. Operating System Utilities: Operating System routines that perform miscellaneous tasks such as getting the date and time, finding out the user's preferred speaker volume and other preferences, and doing simple string comparison. output driver: A device driver that receives data via a serial port and transfers it to an application. III-248 Glossary Glossary overrun error: See hardware overrun error and software overrun error. package: A set of routines and data types that's stored as a resource and brought into memory only when needed. Package Manager: The part of the Toolbox that lets you access Macintosh RAM-based packages. page rectangle : The rectangle marking the boundaries of a printed page image. The boundary rectangle, portRect, and clipRgn of the printing graf?ort are set to this rectangle. palette: A collection of small symbols, usually enclosed in rectangles, that represent operations and can be selected by the user. pane: An independently scrollable area of a window, for showing a different part of the same document panel: An area of a window that shows a different interpretation of the same part of a document. paper rectangle: The rectangle marking the boundaries of the physical sheet of paper on which a page is printed. parameter block: A data structure used to transfer information between applications and certain Operating System routines. parameter RAM: In the clock chip, 20 bytes where settings such as those made with the Control Panel desk accessory are preserved. parity bit: A data communications bit used to verify that data bits received by a device match the data bits transmitted by another device. pa rity error: The condition resulting when the parity bit received by a device isn't what was expected. part code: An integer between 1 and 253 that stands for a particular part of a control (possibly the entire control). path reference number: A number that uniquely identifies an individual access path; assigned when the access path is created. pattern: An 8-by- 8 bit image, used to define a repeating design (such as stripes) or tone (such as gray). pattern transfer mode: One of eight transfer modes for drawing lines or shapes with a pattern. period: The time elapsed during one complete cycle of a wave. phase: Some fraction of a wave cycle (measured from a fixed point on the wave). physical end-of-file: The position of one byte past the last allocation block of a file; equal to 1 more than the maximum number of bytes the file can contain. Glossary Ill-249 Inside Macintosh physical size: The actual number of bytes a memory block occupies within its heap zone. picture: A saved sequence of QuickDraw drawing commands (and, optionally, picture comments) that you can play back later with a single procedure call; also, the image resulting from these commands. picture comments: Data stored in the definition of a picture that doesn't affect the picture's appearance but may be used to provide additional information about the picture when it's played back. picture frame: A rectangle, defined as part of a picture, that surrounds the picture and gives a frame of reference for scaling when the picture is played back. pixel: The visual representation of a bit on the screen (white if the bit is 0, black if it's 1). plane: The front-to-back position of a window on the desktop. point: The intersection of a horizontal grid line and a vertical grid line on the coordinate plane, defined by a horizontal and a vertical coordinate; also, a typographical term meaning approximately 1172 inch. polygon: A sequence of connected lines, defined by QuickDraw line-drawing commands. port: See grafPort. portBits: The bit map of a grafPort. portRect: A rectangle, defined as part of a grafPort, that encloses a subset of the bit map for use by the grafPort. post: To place an event in the event queue for later processing. prime routine: The part of a device driver's code that implements Device Manager Read and Write calls. print record: A record containing all the information needed by the Printing Manager to perform a particular printing job. Printer Driver: The device driver for the currently installed printer. printer resource file: A file containing all the resources needed to run the Printing Manager with a particular printer. printing grafPort: A special grafPort customized for printing instead of drawing on the screen. Printing Manager: The routines and data types that enable applications to communicate with the Printer Driver to print on any variety of printer via the same interface. processor priority: Bits 8-10 of the MC68000's status register, indicating which interrupts will be processed and which will be ignored. 1//-250 Glossary Glossary proportional font: A font whose characters all have character widths that are proportional to their image width. protocol: A well-defined set of communications rules. protocol handler: A software process in a node that recognizes different kinds of frames by their ALAP type and services them. protocol handler table: A list of the protocol handlers for a node. purge: To remove a relocatable block from the heap, leaving its master pointer allocated but set to NIL. purge bit: A bit in the master pointer to a relocatable block that indicates whether the block is currently purgeable. purge warning procedure: A procedure associated with a particular heap zone that's called whenever a block is purged from that zone. purgeable block: A relocatable block that can be purged from the heap. queue: A list of identically structured entries linked together by pointers. QuickDraw: The part of the Toolbox that performs all graphic operations on the Macintosh screen. radio button: A standard Macintosh control that displays a setting, either on or off, and is part of a group in which only one button can be on at a time. RAM: The Macintosh's random access memory, which contains exception vectors, buffers used by hardware devices, the system and application heaps, the stack, and other information used by applications. read/write permission: Information associated with an access path that indicates whether the file can be read from, written to, both read from and written to, or whatever the file's open permission allows. reallocate: To allocate new space in the heap for a purged block, updating its master pointer to point to its new location. reference number: A number greater than 0, returned by the Resource Manager when a resource file is opened, by which you can refer to that file. In Resource Manager routines that expect a reference number, 0 represents the system resource file. reference value: In a window record or control record, a 32-bit field that an application program may store into and access for any purpose. region: An arbitrary area or set of areas on the Quick.Draw coordinate plane. The outline of a region should be one or more closed loops. register-based routine: A Toolbox or Operating System routine that receives its parameters and returns its results, if any, in registers. Glossary lll-251 Inside Macintosh relative handle: A handle to a relocatable block expressed as the offset of its master pointer within the heap zone, rather than as the absolute memory address of the master pointer. release: To free an allocated area of memory, making it available for reuse. release timer: A timer for determining when an exactly-once response buffer can be released. relocatable block: A block that can be moved within the heap during compaction. resource: Data or code stored in a resource file and managed by the Resource Manager. resource attribute: One of several characteristics, specified by bits in a resource reference, that determine how the resource should be dealt with. resource data: In a resource file, the data that comprises a resource. resource file: The resource fork of a file. resource fork: The part of a file that contains data used by an application (such as menus, fonts, and icons). The resource fork of an application file also contains the application code itself. resource header: At the beginning of a resource file, data that gives the offsets to and lengths of the resource data and resource map. resource ID: A number that, together with the resource type, identifies a resource in a resource file. Every resource has an ID number. Resource Manager: The part of the Toolbox that reads and writes resources. resource map: In a resource file, data that is read into memory when the file is opened and that, given a resource specification, leads to the corresponding resource data. resource name: A string that, together with the resource type, identifies a resource in a resource file. A resource may or may not have a name. resource reference: In a resource map, an entry that identifies a resource and contains either an offset to its resource data in the resource file or a handle to the data if it's already been read into memory. resource specification: A resource type and either a resource ID or a resource name. resource type: The type of a resource in a resource file, designated by a sequence of four characters (such as 'MENU' for a menu). response BDS: A data structure used to pass response information to the ATP module. result code: An integer indicating whether a routine completed its task successfully or was prevented by some error condition (or other special condition, such as reaching the end of a file). resume procedure: A procedure within an application that allows the application to recover from system errors. Ill-252 Glossary Glossary retry count: The maximum number of retransmissions for an NBP or ATP packet. retry interval: The time between retransmissions of a packet by NBP or ATP. ROM: The Macintosh's permanent read-only memory, which contains the routines for the Toolbox and Operating System, and the various system traps. routine selector: An integer that's pushed onto the stack before the _PackN macro is invoked, to identify which routine to execute. (N is the resource ID of a package; all macros for calling routines in the package expand to invoke _PackN.) routing table: A table in a bridge that contains routing information. Routing Table Maintenance Protocol (RTMP): An AppleTalk protocol that's used internally by AppleTalk to maintain tables for routing datagrams through an internet. row width: The number of bytes in each row of a bit image. RTMP: See Routing Table Maintenance Protocol. RTMP socket: The socket in a node used to implement RTMP. R TMP stub: The RTI\1P code in a nonbridge node. scaling factor: A value, given as a fraction, that specifies the amount a character should be stretched or shrunk before it's drawn. SCC: See Serial Communications Controller. scrap: A place where cut or copied data is stored. scrap file: The file containing the desk scrap (usually named "Clipboard File"). Scrap Manager: The part of the Toolbox that enables cutting and pasting between applications, desk accessories, or an application and a desk accessory. screen buffer: A block of memory from which the video display reads the information to be displayed. sector: Disk space composed of 512 consecutive bytes of standard information and 12 bytes of file tags. segment: One of several parts into which the code of an application may be divided. Not all segments need to be in memory at the same time. Segment Loader: The part of the Operating System that loads the code of an application into memory, either as a single unit or divided into dynamically loaded segments. selection range: The series of characters (inversely highlighted), or the character position (marked with a blinking caret), at which the next editing operation will occur. Glossary III-253 Inside Macintosh sequence number: A number from 0 to 7, assigned to an ATP response datagram to indicate its ordering within the response. Serial Communications Controller (SCC): The chip that handles serial I/O through the modem and printer ports. serial data: Data communicated over a single-path communication line, one bit at a time. Serial Driver: A device driver that controls communication, via serial ports, between applications and serial peripheral devices. signature: A four-character sequence that uniquely identifies an application to the Finder. socket: A logical entity within the node of a network. socket client: A software process in a node that owns a socket. socket listener: The portion of a socket client that receives and services datagrams addressed to that socket. socket number: An identifier for a socket. socket table: A listing of all the socket listeners for each active socket in a node. software overrun error: The condition that occurs when an input driver's buffer becomes full. solid shape: A shape that's filled in with any pattern. sound buffer: A block of memory from which the sound generator reads the information to create an audio waveform. Sound Driver: The device driver that controls sound generation in an application. sound procedure: A procedure associated with an alert that will emit one of up to four sounds from the Macintosh's speaker. Its integer parameter ranges from 0 to 3 and specifies which sound. source transfer mode: One of eight transfer modes for drawing text or transferring any bit image between two bit maps. space state: The state of a transmission line indicating a binary 0. spool printing: Writing a representation of a document's printed image to disk or to memory, and then printing it (as opposed to immediate draft printing). square-wave synthesizer: The part of the Sound Driver used to produce less harmonic sounds than the four-tone synthesizer, such as beeps. stack: The area of memory in which space is allocated and released in LIFO (last-in-first-out) order. 111-254 Glossary Glossary stack-based routine: A Toolbox or Operating System routine that receives its parameters and returns its results, if any, on the stack. stack frame: The area of the stack used by a routine for its parameters, return address, local variables, and temporary storage. stage: Every alert has four stages, corresponding to consecutive occurrences of the alert, and a different response may be specified for each stage. Standard File Package: A Macintosh package for presenting the standard user interface when a file is to be saved or opened. start bit: A serial data communications bit that signals that the next bits transmitted are data bits. status information: Information transmitted to an application by a device driver. It may indicate the current mode of operation, the readiness of the device, the occurrence of errors, and so on. status routine: The part of a device driver's code that implements Device Manager Status calls. stop bit: A serial data communications bit that signals the end of data bits. structure region: An entire window; its complete "structure". style: See character style. style dialog: A dialog that sets options affecting the page dimensions; associated with the Page Setup command. synchronous execution: After calling a routine synchronously, an application cannot continue execution until the routine is completed. synthesizer: See free-form, four-tone, or square-wave synthesizer. synthesizer buffer: A description of the sound to be generated by a synthesizer. system error alert: An alert box displayed by the System Error Handler. system error alert table: A resource that determines the appearance and function of system error alerts. System Error Handler: The part of the Operating System that assumes control when a fatal system error occurs. system error ID: An ID number that appears in a system error alert to identify the error. system event mask: A global event mask that controls which types of events get posted into the event queue. system font: The font that the system uses (in menus, for example). Its name is Chicago. system font size: The size of text drawn by the system in the system font; 12 points. Glossary III-255 Inside Macintosh system heap: The portion of the heap reserved for use by the Operating System. system heap zone: The heap zone provided by the Memory Manager for use by the Operating System; equivalent to the system heap. system resource: A resource in the system resource file. system resource file: A resource file containing standard resources, accessed if a requested resource wasn't found in any of the other resource files that were searched. system startup information: Certain configurable system parameters that are stored in the first two logical blocks of a volume and read in at system startup. system window: A window in which a desk accessory is displayed. TextEdit: The part of the Toolbox that supports the basic text entry and editing capabilities of a standard Macintosh application. TextEdit scrap: The place where certain TextEdit routines store the characters most recently cut or copied from text thousands separator: The character that separates every three digits to the left of the decimal point. thumb: The Control Manager's term for the scroll box (the indicator of a scroll bar). tick: A sixtieth of a second. Toolbox: Same as User Interface Toolbox. Toolbox Event Manager: The part of the Toolbox that allows your application program to monitor the user's actions with the mouse, keyboard, and keypad. Toolbox Utilities: The part of the Toolbox that performs generally useful operations such as fixed-point arithmetic, string manipulation, and logical operations on bits. track: Disk space composed of 8 to 12 consecutive sectors. A track corresponds to one ring of constant radius around the disk. transaction: A request-response communication between two ATP clients. See transaction request and transaction response. transaction ID : An identifier assigned to a transaction. transaction request: The initial part of a transaction in which one socket client asks another to perform an operation and return a response. transaction response: The concluding part of a transaction in which one socket client returns requested information or simply confirms that a requested operation was performed. Transcendental Functions Package: A Macintosh package that contains trigonometric, logarithmic, exponential, and financial functions, as well as a random number generator. ///-256 Glossary Glossary transfer mode: A specification of which Boolean operation QuickDraw should perform when drawing or when transfening a bit image from one bit map to another. trap dispatch table: A table in RAM containing the addresses of all Toolbox and Operating System routines in encoded form. trap dispatcher: The part of the Operating System that examines a trap word to determine what operation it stands for, looks up the address of the corresponding routine in the trap dispatch table, and jumps to the routine. trap macro: A macro that assembles into a trap word, used for calling a Toolbox or Operating System routine from assembly language. trap number: The identifying number of a Toolbox or Operating System routine; an index into the trap dispatch table. trap word: An unimplemented instruction representing a call to a Toolbox or Operating System routine. unimplemented instruction: An instruction word that doesn't correspond to any valid machine-language instruction but instead causes a trap. unit number: The number of each device driver's entry in the unit table. unit table: A 128-byte nonrelocatable block containing a handle to the device control entry for each device driver. unlock: To allow a relocatable block to be moved during heap compaction. unmounted volume: A volume that hasn't been inserted into a disk drive and had descriptive information read from it, or a volume that previously was mounted and has since had the memory used by it released. unpurgeable block: A relocatable block that can't be purged from the heap. update event: An event generated by the Window Manager when a window's contents need to be redrawn. update region: A window region consisting of all areas of the content region that have to be redrawn. user bytes: Four bytes in an ATP header provided for use by ATP's clients. User Interface Toolbox: The software in the Macintosh ROM that helps you implement the standard Macintosh user interface in your application. validity status: A number stored in parameter RAM designating whether the last attempt to write there was successful. (The number is $A8 if so.) variation code: The part of a window or control definition ID that distinguishes closely related types of windows or controls. Glossary 1//-257 Inside Macintosh VBL task: A task performed during the vertical retrace interrupt. vector table: A table of interrupt vectors in low memory. version data: In an application's resource file, a resource that has the application's signature as its resource type; typically a string that gives the name, version number, and date of the application. version number: A number from 0 to 255 used to distinguish between files with the same name. Versatile Interface Adapter (VIA) : The chip that handles most of the Macintosh's 1/0 and interrupts. vertical blanking interrupt: See vertical retrace interrupt. vertical blanking interval: The time between the display of the last pixel on the bottom line of the screen and the first one on the top line. vertical retrace interrupt: An interrupt generated 60 times a second by the Macintosh video circuitry while the beam of the display tube returns from the bottom of the screen to the top; also known as vertical blanking interrupt. Vertical Retrace Manager: The part of the Operating System that schedules and executes tasks during the vertical retrace interrupt. vertical retrace queue: A list of the tasks to be executed during the vertical retrace interrupt. VIA: See Versatile Interface Adapter. view rectangle: In TextEdit, the rectangle in which the text is visible. visible control: A control that's drawn in its window (but may be completely overlapped by another window or other object on the screen). visible window: A window that's drawn in its plane on the desktop (but may be completely overlapped by another window or object on the screen). visRgn: The region of a gratPort, manipulated by the Window Manager, that's actually visible on the screen. volume: A piece of storage medium formatted to contain files; usually a disk or part of a disk. A 400K-byte 3 1/2-inch Macintosh disk is one volume. volume allocation block map: A list of 12-bit entries, one for each allocation block, that indicate whether the block is currently allocated to a file, whether it's free for use, or which block is next in the file. Block maps exist both on volumes and in memory. volume attributes: Information contained on volumes and in memory indicating whether the volume is locked, whether it's busy (in memory only), and whether the volume control block matches the volume information (in memory only). ll/-258 Glossary Glossary volume buffer: Memory used initially to load the master directory block, and used thereafter for reading from files that are opened without an access path buffer. volume control block: A nonrelocatable block that contains volume-specific information, including the volume information from the master directory block. volume-control-block queue: A list of the volume control blocks for all mounted volumes. volume index: A number identifying a mounted volume listed in the volume-control-block queue. The first volume in the queue has an index of l, and so on. volume information: Volume-specific information contained on a volume, including the volume name and the number of files on the volume. volume name: A sequence of up to 27 printing characters that identifies a volume; followed by a colon(:) in File Manager routine calls, to distinguish it from a file name. volume reference number: A unique number assigned to a volume as it's mounted, used to refer to the volume. waveform: The physical shape of a wave. waveform description: A sequence of bytes describing a waveform. wavelength: The horizontal extent of one complete cycle of a wave. window: An object on the desktop that presents information, such as a document or a message. window class: In a window record, an indication of whether a window is a system window, a dialog or alert window, or a window created directly by the application. window definition function: A function called by the Window Manager when it needs to perform certain type-dependent operations on a particular type of window, such as drawing the window frame. window definition ID: A number passed to window-creation routines to indicate the type of window. It consists of the window definition function's resource ID and a variation code. window frame: The structure region of a window minus its content region. window list: A list of all windows ordered according to their front-to-back positions on the desktop. Window Manager: The part of the Toolbox that provides routines for creating and manipulating windows. Window Manager port: A grafPort that has the entire screen as its portRect and is used by the Window Manager to draw window frames. window record: The internal representation of a window, where the Window Manager stores all the information it needs for its operations on that window. Glossary III-259 Inside Macintosh window template: A resource that contains information from which the Window Manager can create a window. word: In TextEdit, any series of printing characters, excluding spaces (ASCII code $20) but including nonbreaking spaces (ASCII code $CA). word wraparound: Keeping words from being split between lines when text is drawn. write data structure: A data structure used to pass information to the ALAP or DDP modules. zone: An arbitrary subset of AppleTalk networks in an internet. See also heap zone. zone header: The internal "housekeeping" information maintained by the Memory Manager at the beginning of each heap zone. zone pointer: A pointer to a zone record. zone record: A data structure representing a heap zone. zone trailer: A minimum-size free block marking the end of a heap zone. III-260 Glossary INDEX A amplitude of a wave 11-223 AngleFromSlope function 1-476 ABByte data type 11-276 ANumber global variable 1-423 ABCallType data type 11-274 ApFontID global variable 1-219 ABProtoType data type II-274 AppendMenu procedure 1-352 ABRecHandle data type II-274 AppFile data type 11-58 ABRecPtr data type II-274 Apple menu 1-54 ABusRecord data type 11-274 AppleTalk address 11-265 ALAP parameters 11-276 AppleTalk Link Access Protocol 11-263 ATP parameters II-287 assembly language II-306 DDP parameters 11-281 data reception JI-325 NBP parameters 11-298 Pascal 11-276 ABusVars global variable II-328 AppleTalk Manager 1-13; 11-261, 271 access path 11-83 assembly language 11-304 access path buffer II-84 Pascal 11-273 ACount global variable 1-423 AppleTalk Transaction Protocol 11-266, 267 action procedure 1-316, 324, 328 assembly language 11-312 in control definition function 1-332 Pascal 11-287 activate event 1-244, 279 application font I-219 event message 1-252 application heap 1-74; II-9 active limit II-17, 29 control I-313 application parameters 11-20 window 1-46, 270, 284 application space 11-20 AddPt procedure 1-193 application window 1-270 AddrBlock data type 11-281 ApplicZone function 11-32 AddResMenu procedure I-353 App!Limit global variable 11-19, 21 , 29 AddResource procedure 1-124 AppIScratch global variable 1-85 AddResponse function 11-318 AppIZone global variable II-19, 21, 32 address mark II-211 AppParmHandle global variable II-57 ALAP See AppleTalk Link Access Protocol a1rnw cursor 1-163, 167 ALAP frame II-264 arrow global variable 1-147, 163 ALAP protocol type 11-264 ascent of a font 1-228 alert 1-401, 409 in TextEdit 1-378 guidelines 1-68 ASCII codes 1-247 alert box 1-401 assembly language 1-83 Alert function I-418 asynchronous communication II-245 alert stages 1-409 asynchronous execution alert template 1-403, 424 AppleTalk Manager II-273 resource format 1-426 Device Manager 11-180 alert window 1-402 File Manager 11-97 AlertTemplate data type 1-424 at-least-once transaction II-266 AlertTHndl data type 1-425 ATP See AppleTalk Transaction Protocol AlertTPtr data type 1-425 ATPAddRsp function 11-295 alias 11-266 ATPCloseSocket function 11-291 Allocate function ATPGetRequest function II-293 high-level 11-94 ATPLoad function 11-290 low-level 11-113 ATPOpenSocket function 11-290 allocated block 11-10 ATPReqCancel function 11-293 allocation block 11-79 ATPRequest function 11-292 JJl-261 Inside Macintosh ATPResponse function 11-296 BlockMove procedure 11-44 ATPRspCancel function II-296 boot blocks See system startup information ATPSndRequest function 11-291 boundary rectangle 1-144 ATPSndRsp function 11-294 break 11-246 ATPUnload function 11-290 bridge II-265 AttachPH function 11-308 BringToFront procedure 1-286 auto-key event 1-244, 246 broadcast service 11-264 auto-key rate 1-246; 11-371 ButPtr global variable 11-19, 21 auto-key threshold 1-246; II-371 BuffgDate global variable II-212 auto-pop bit 1-89 BuffgFBkNum global variable 11-212 automatic scrolling 1-48 BuffgFFlag global variable 11-212 in TextEdit 1-380 BuffgFNum global variable 11-212 bundle 11-85; IIl-11 resource format III-12 B Button function 1-259 button type of control 1-311, 404 BackColor procedure 1-174 Byte data type 1-78 background procedure Il-153 BackPat procedure 1-167 base line 1-227 c baud rate 11-246, 251, 254 BDSElement data type II-288 CalcMenuSize procedure 1-361 BDSPtr data type II-288 CalcVBehind procedure 1-297 BDSType data type 11-288 Cale Vis procedure 1-297 BeginUpdate procedure 1-292 CalcVisBehind procedure 1-297 Binary-Decimal Conversion Package 1-12, caret 1-376, 379 487 caret-blink time I-260; 11-371 bitimage 1-143 CaretTime global variable 1-260 bit manipulation 1-470 CautionAlert function 1-420 bit map Chain procedure 11-59 AppleTalk Manager 11-268 ChangedResource procedure I-1 23 printing 11-164 character codes 1-246 QuickDraw I-144 character device II-175 BitAnd function 1-471 character image 1-227 BitClr procedure 1-471 character keys 1-33, 246 BitMap data type 1-144 character offset 1-228 BitMapType data type 11-287 character origin 1-228 BitNot function I-471 character position I-375 BitOr function 1-471 character rectangle 1-228 Bits16 data type 1-146 character set 1-247 BitSet procedure 1-471 character style 1-151 BitShift function I-472 of menu items 1-348, 360 BitTst function 1-471 character width 1-173, 228 BitXor function 1-471 Chars data type 1-384 black global variable 1-162 CharsHandle data type 1-384 block (file) See allocation block CharsPtr data type 1-384 block (memory) I-73 ; II-10 CharWidth function 1-173 block contents II-10 check box 1-312, 404 block device 11-175 check mark in a menu I-347, 358 block header II-10 Checkltem procedure 1-358 structure 11-24 CheckUpdate function I-296 block map II-122 ClearMenuBar procedure 1-354 III-262 Index click See mouse-down event control 1-65, 311 click loop routine 1-380 defining your own 1-328 ClipAbove procedure 1-296 in a dialog/alert I-404 Clipboard I-58 See also scrap control definition function 1-314, 328 clipping region of a grafPort I-149 control definition ID I-315, 328 ClipRect procedure 1-167 Control function clipRgn of a grafPort 1-149 high-level II-179 clock chip 11-369 low-level II-186 hardware 111-36 control information 11-176 close box See go-away region control list 1-274, 317 Close command 1-56 Control Manager 1-11, 309 Close function, high-level routines 1-319 Device Manager 11-178 control record 1-316 File Manager 11-94 control routine Close function, low-level of a desk accessory I-446 Device Manager II-184 of a driver 11-187, 194 File Manager 11-114 control template 1-315 close routine resource format 1-332 of a desk accessory 1-446 ControlHandle data type 1-317 of a driver 11-187, 193 ControlPtr data type 1-317 CloseATPSkt function 11-316 ControlRecord data type 1-317 closed device driver 11-176 coordinate plane I-138 closed file 11-83 CopyBits procedure I-188 CloseDeskAcc procedure 1-440 CopyRgn procedure 1-183 CloseDialog procedure 1-413 CouldAlert procedure 1-420 CloseDriver function Il-178 CouldDialog procedure I-415 ClosePgon procedure I-190 CountAppFiles procedure II-57 ClosePicture procedure 1-189 CountMitems function 1-361 ClosePoly procedure I-190 CountResources function 1-118 ClosePort procedure I-164 CountTypes function 1-117 CloseResFile procedure I-115 Create function CloseRgn procedure I-182 high-level 11-90 CloseSkt function 11-312 low-level II-107 CloseWindow procedure I-283 CreateResFile procedure 1-114 ClrAppFiles procedure II-58 creator of a file III-9 CmpString function II-377 CrsrThresh global variable 11-372 color drawing 1-158, 173 CurActivate global variable 1-280 ColorBit procedure I-174 CurApName global variable II-58 Command-key equivalent See keyboard CurApRefNum global variable 11-58 equivalent CurDeactive global variable 1-280 Command-period II-154 CurJTOffset global variable II-62 Command-Shift-number I-258 CurMap global variable I-117 commands 1-51, 341 CurPageOption global variable II-60 compaction, heap 1-74; 11-12, 39 CurPitch global variable 11-226, 232 CompactMem function II-39 current heap zone 11-10, 31 completion routine current resource file 1-105, 116 Device Manager II-180, 181 CurrentA5 global variable 1-95; 11-19, 21, File Manager 11-97, 99 386 Sound Driver II-231 CurResFile function I-116 ConfirmName function II-323 CursHandle data type 1-474 content region of a window 1-271 III-263 Inside Macintosh cursor 1-146 DeleteMenu procedure 1-354 QuickDraw routines 1-167 DeltaPoint function I-475 standard cursors I-147, 474 Dequeue function II-383 utility routines 1-474 dereferencing a handle 11-14 Cursor data type I-146 descent of a font I-228 cursor level 1-167 desk accessory 1-437 CursPtr data type I-474 writing your own 1-443 CurStackBase global variable 11-19, 21, 358 Desk Manager I-12, 435 cut and paste 1-59 routines 1-440 intelligent 1-63 desk scrap 1-453 in TextEdit 1-385 data types I-454 format I-462 routines 1-457 D DeskHook global variable I-282, 288 DeskPattem global variable I-282 DABeeper global variable 1-411 desktop 1-32, 269 DAStrings global array 1-421 Desktop file III-10 data bits 11-245 destination rectangle I-374 data buffer 11-83, 176 DetachPH function II-308 data fork 1-105; 11-81 DetachResource procedure 1-120 data mark 11-211 device 11-175 datagram 11-265 device control entry II-1 89 loss recovery 11-268 device driver 1-13; II-175 Datagram Delivery Protocol 11-265 for a desk accessory 1-443 assembly language 11-308 structure 11-187 Pascal II-281 writing your own Il-193 date operations 11-377 device driver event 1-244 Date2Secs procedure 11-379 Device Manager I-13; II-173 DateForm data type 1-504 Device Manager routines 11-177 date/time record 11-377 device control entry access Il-190 DateTimeRec data type II-378 high-level II-178 DCtlEntry data type 11-190 low-level Il-180 DCtlHandle data type II-190 for writing drivers Il-194 DCtlPtrdata type 11-190 dial 1-312 DDP See Datagram Delivery Protocol dialog box 1-66, 399 DDPCloseSocket function 11-282 Dialog Manager I-12, 397 DDPOpenSocket function 11-282 routines 1-411 DDPRdCancel function 11-284 dialog pointer I-407 DDPRead function 11-283 dialog record I-403, 407 DDPWrite function 11-283 dialog template 1-402, 403 default button resource format 1-425 in an alert I-69, 401, 424 dialog window 1-401 in a dialog 1-67, 400, 407 DialogPeek data type 1-408 default volume 11-80 DialogPtr data type 1-407 getting See GetVol function DialogRecord data type I-408 setting See SetVol function DialogSelect function I-417 DefltStack global variable 11-17 DialogTemplate data type 1-423 DefVCBPtr global variable 11-126 DialogTHndl data type 1-424 Delay procedure 11-384 DialogTPtr data type 1-424 Delete function DIBadMount function II-396 high-level 11-97 DiffRgn procedure I-1 84 low-level 11-119 DIFormat function Il-398 JJJ-264 Index DILoad procedure II-396 drag region of a window 1-271, 289 dimmed DragControl procedure 1-325 control 1-313 DragGrayRgn function 1-294 menu item 1-342, 343 DragHook global variable menu title 1-342 Control Manager 1-324, 326 disabled Window Manager 1-288, 289, 290, 295 dialog/alert item 1-405 DragPattem global variable menu 1-342, 358 Control Manager 1-324, 326 menu item 1-349, 358 Window Manager 1-295 Disableltem procedure 1-358 DragTheRgn function 1-295 discontinuous selection 1-40 DragWindow procedure 1-289 Disk Driver 1-13; 11-209 DrawChar procedure 1-172 Device Manager calls 11-213 DrawControls procedure 1-322 routines 11-214 DrawDialog procedure 1-418 Disk Initialization Package 1-13; 11-393 DrawGrowlcon procedure 1-287 routines 11-396 drawing 1-155 disk-inserted event 1-244 color 1-158, 173 event message I-252 DrawMenuBar procedure 1-354 responding to 1-257 DrawNew procedure 1-296 disk interface ill-33 DrawPicture procedure 1-190 disk-switch dialog Il-80 DrawString procedure 1-172 DiskEject function 11-214 DrawText procedure 1-172 dispatch table See trap dispatch table drive number 11-80 display rectangle 1-406 drive queue 11-127 DisposControl procedure 1-321 driver See device driver DisposDialog procedure 1-415 driver 110 queue 11-180, 191 DisposeControl procedure 1-321 driver name 11-176 DisposeMenu procedure 1-352 driver reference number 11-176 DisposeRgn procedure 1-182 DriveStatus function 11-215 DisposeWindow procedure 1-284 DrvQEl data type 11-127 DisposHandle procedure 1-76, 80; 11-33 DrvQHdr global variable Il-128 DisposMenu procedure 1-352 DrvSts data type II-215 DisposPtr procedure 1-75, 79; 11-36 DSAlertRect global variable 11-362 DisposRgn procedure 1-182 DSAlertTab global variable 11-359, 362 DisposWindow procedure 1-284 DSErrCode global variable 11-362 DIUnload procedure 11-396 DIVerify function 11-398 DIZero function 11-399 E dkGray global variable 1-162 DlgCopy procedure 1-418 Edit menu 1-58 DlgCut procedure 1-418 and desk accessories 1-441, 447 DlgDelete procedure 1-418 edit record 1-374 DlgFont global variable 1-412 Eject function DlgHook function high-level 11-90 SFGetFile 1-526 low-level 11-107 SFPutFile 1-522 Elems68K See Transcendental Functions DlgPaste procedure 1-418 Package document window 1-269 empty handle 1-76; Il-14, 40 double-click 1-37, 255 EmptyHandle procedure 11-40 double-click time 1-260; II-371 EmptyRect function 1-176 DoubleTime global variable 1-260 EmptyRgn function 1-186 draft printing 11-151, 153 111-265 Inside Macintosh enabled external reference 1-95 dialog/alert item 1-405 ExtStsDT global variable 11-199 menu 1-358 menu item I-358 Enableltem procedure 1-358 F end-of-file II-81 end-of-message flag 11-270 FCBSPtr global variable II-127 EndUpdate procedure 1-293 Fetch function 11-194 Enqueue procedure 11-382 FFSynthPtr data type II-228 entity name II-265, 298 FFSynthRec data type II-228 EntityName data type II-298 file II-79, 81 Environs procedure 11-385 file control block II-126 EntityPtr data type 11-298 file-control-block buffer 11-126 equal-tempered scale 11-237 file creator III-9 EqualPt function 1-193 file directory II-79, 122 EqualRect function 1-176 file icon 11-85; Ill-10 EqualRgn function 1-185 file 1/0 queue II-97, 124 EqualString function 11-377 File Manager 1-13; 11-77 EraseArc procedure I-180 File Manager routines EraseOval procedure 1-178 high-level II-88 ErasePoly procedure I-192 low-level 11-97 EraseRect procedure 1-177 for queue access II-125, 126, 128 EraseRgn procedure 1-186 File menu 1-55 EraseRoundRect procedure 1-179 file name II-81 error number See result code file number 11-122 ErrorSound procedure 1-411 file reference III-10 event 1-243 resource format III-12 priority 1-245 file tags 11-212 event code 1-249 file tags buffer 11-212 Event Manager, Operating System 1-13; 11-65 file type III-9 routines 11-68 fileFilter function 1-524 Event Manager, Toolbox 1-11, 241 FillArc procedure 1-181 routines 1-257 FillOval procedure 1-178 event mask 1-253 FillPoly procedure 1-192 event message 1-249 FiIIRect procedure 1-1 77 event queue 1-243 FillRgn procedure 1-187 structure II-70 FillRoundRect procedure 1-179 event record 1-249 filterProc function 1-415 event types 1-244 financial functions 11-407 EventAvail function 1-259 FindControl function I-323 EventQueue global variable Il-71 Finder information 11-55 EventRecord data type 1-249 Finder interface II-55, 84; III-7 EvQEl data type 11-71 FinderName global variable II-59 exactly-once transaction 11-266 FindWindow function I-287 example program I-13 Flnfo data type 11-84 exception 11-195 FinitQueue procedure 11-103 exception vector III-17 Fixed data type I-79 ExitToShell procedure 11-59 fixed-point exponential functions 11-407 arithmetic I-467 extended selection I-39 numbers 1-79 in TextEdit 1-384 fixed-width font 1-228 external file system 11-128 FixMul function I-467 III-266 Index FixRatio function 1-467 FrameRgn procedure 1-186 FixRound function 1-467 FrameRoundRect procedure 1-178 FlashMenuBar procedure 1-361 framing error 11-246 Floating-Point Arithmetic Package 1-13; 11-403 free-form synthesizer 11-223, 228 FlushEvents procedure 11-69 free memory block 11-10 FlushFile function 11-114 FreeAlert procedure 1-420 FlushVol function FreeDialog procedure 1-415 high-level 11-89 FreeMem function 11-38 low-level 11-105 FreeWave data type 11-228 FMlnput data type 1-224 frequency of a wave II-223 FMOutPtr data type 1-227 FrontWindow function 1-286 FMOutput data type 1-227 FScaleDisable global variable 1-222 FMSwapFont function 1-223 FSClose function 11-94 folder 11-85 FSDelete function II-97 font 1-60, 151, 217 FSOpen function 11-91 characters 1-220 FSQHdr global variable 11-125 format 1-227 FSRead function resource format 1-234 Device Manager II-178 resource ID 1-234 File Manager 11-92 font characterization table 1-225 FSWrite function font height 1-228 Device Manager 11-179 Font Manager 1-11, 215 File Manager 11-92 communication with QuickDraw 1-224 FI'SndRecPtr data type 11-227 routines 1-222 FI'SoundRec data type 11-227 Font menu 1-60, 353 FI'SynthPtr data type 11-227 font number 1-217, 219 FI'SynthRec data type 11-227 font record 1-230 full-duplex communication 11-245 font rectangle 1-228 font scaling 1-220 font size 1-153, 217 G Fontinfo data type 1-173 FontRec data type 1-231 GetAlrtStage function 1-422 FontSize menu 1-61 GetAppFiles procedure 11-58 ForeColor procedure 1-173 GetApplLimit function 11-29 fork 1-105; 11-81 GetAppParms procedure II-58 four-tone record 11-227 GetCaretTime function 1-260 four-tone synthesizer 11-223, 226 GetClip procedure 1-167 FP68K See Floating-Point Arithmetic Package GetCRefCon function 1-327 frame GetCTitle procedure 1-321 ALAP 11-264 GetCtlAction function 1-328 picture 1-158 GetCtlMax function 1-327 serial communication 11-246 GetCtlMin function 1-327 stack 1-96; 11-17 GetCtlValue function 1-326 window 1-271 GetCursor function 1-474 frame check sequence 11-265 GetDateTime procedure 11-378 frame header 11-264 GetDblTime function 1-260 frame pointer (stack) 1-96 GetDCtlEntry function 11-190 frame trailer 11-264 GetDltem procedure 1-421 FrameArc procedure 1-180 GetDrvQHdr function 11-128 FrameOval procedure 1-177 GetEOF function FramePoly procedure 1-192 high-level 11-93 FrameRect procedure 1-17 6 low-level 11-112 III-267 Inside Macintosh GetEvQHdr function 11-71 GetResFileAttrs function 1-127 GetFilelnfo function GetReslnfo procedure 1-121 high-level II-95 GetResource function 1-119 low-level 11-115 GetRMenu function 1-351 GetFinfo function II-95 GetScrap function 1-469 GetFName procedure 1-223 GetSoundVol procedure II-232 GetFNum procedure 1-223 GetString function 1-468 GetFontlnfo procedure 1-173 GetSysPPtr function 11-381 GetFontName procedure 1-223 GetTime procedure 11-380 GetFPos function GetTrapAddress function 11-384 high-level II-92 GetVBLQHdr function II-352 low-level 11-111 GetVCBQHdr function 11-126 GetFSQHdr function 11-125 GetVInfo function II-89 GetHandleSize function 11-33 GetVol function Getlcon function 1-473 high-level 11-89 GetlndPattern procedure 1-473 low-level ll-104 GetlndResource function 1-118 GetVollnfo function GetlndString procedure 1-468 high-level 11-89 GetlndType procedure 1-117 low-level 11-104 Getltem procedure 1-358 GetVRefNum function II-89 Getltemlcon procedure 1-360 GetWindowPic function 1-293 GetltemMark procedure 1-359 GetWMgrPort procedure 1-282 GetltemStyle procedure 1-360 GetWRefCon function 1-293 GetlText procedure I-422 GetWTitle procedure 1-284 Getltmlcon procedure 1-360 GetZone function 11-31 GetltmMark procedure 1-359 GhostWindow global variable 1-287 GetltmStyle procedure I-360 global coordinates I-155 GetKeys procedure 1-259 global variables GetMaxCtl function I-327 list III-227 GetMenu function 1-351 QuickDraw 1-138, 162 GetMenuBar function I-355 GlobalToLocal procedure 1-193 GetMHandle function I-361 go-away region of a window 1-271, 288 GetMinCtl function 1-327 GrafDevice procedure 1- 165 GetMouse procedure 1-259 grafPort 1-147 GetNamedResource function 1- 119 routines 1-162 GetNewControl function 1-321 GrafPort data type 1-148 GetNewDialog function I-413 GrafPtr data type 1-148 GetNewMBar function 1-354 GrafVerb data type 1-198 GetNewWindow function 1-283 gray global variable I-162 GetNextEvent function 1-257 GrayRgn global variable I-282, 296 GetNodeAddress function II-303 grow image of a window 1-289 GetOSEvent function II-69 grow region of a window I-272, 289 GetPattem function 1-473 grow zone function 11-14, 42 GetPen procedure 1-169 GrowWindow function 1-289 GetPenState procedure 1-169 GZRootHnd global variable 11-43 GetPicture function 1-475 GZSaveHnd function 11-43 GetPixel function 1-195 GetPort procedure 1-165 GetPtrSize function II-37 H GetRequest function 11-317 GetResAttrs function 1-121 HandAndHand function 11-375 ///-268 Index handle 1-75, 78; II-12 lnitApplZone procedure II-28 dereferencing 11-14 Ini tCursor procedure 1-167 empty 11-40 lnitDialogs procedure 1-411 manipulation 11-374 lnitFonts procedure I-222 Handle data type 1-78 Ini tGraf procedure 1-162 HandleZone function 11-34 lnitMenus procedure 1-351 HandToHand function 11-374 lnitPack procedure 1-484 hardware 111-15 lnitPort procedure 1-164 hardware overrun error II-246 InitQueue procedure 11-103 heap 1-12, 23; 11-9, 17 InitResources function 1-114 compaction I-74; 11-12, 39 InitUtil function 11-380 creating on the stack 11-45 InitWindows procedure I-281 zone 11-9, 22 InitZone procedure 11-29 HeapEnd global variable 11-19, 21 input driver 11-246 HideControl procedure 1-322 insertion point 1-41, 375 HideCursor procedure 1-168 lnsertMenu procedure 1-353 HidePen procedure 1-168 lnsertResMenu procedure 1-353 HideWindow procedure 1-283 lnsetRect procedure 1-175 highlighted 1-31 InsetRgn procedure 1-184 control 1-313 lnt64Bit data type 1-472 menu title 1-357 interface routine 1-95 window 1-270 international resources 1-495 HiliteControl procedure 1-322 International Utilities Package 1-12, 493 HiliteMenu procedure 1-357 routines 1-504 HiliteWindow procedure 1-286 internet 11-265 HiWord function 1-472 internet address 11-265, 314 HLock procedure 11-41 interrupt 11-195 HNoPurge procedure II-42 level-1 (VIA) II-197; III-38 HomeResFile function 1-117 level-2 (SCC) 11-198 horizontal blanking interval III-18 level-3 11-196 hotSpot of a cursor 1-146 vertical retrace 11-349 HPurge procedure 11-41 interrupt handler 11-195 HUnlock procedure 11-41 writing your own 11-200 interrupt priority level 11-196 interrupt vector 11-196 IntlOHndl data type 1-496 IntlOPtr data type I-496 icon 1-32 IntlORec data type 1-497 in a dialog/alert 1-404 lntllHndl data type 1-500 for a file 11-85; III-10 lntllPtr data type 1-500 in a menu 1-347, 359 IntllRec data type 1-500 utility routines 1-473 InvalRect procedure 1-291 icon list III-11 lnvalRgn procedure 1-291 resource format 1-476; III-12 lnverRect procedure 1-177 icon number 1-347 lnverRgn procedure 1-1 86 image width 1-228 lnverRoundRect procedure 1-179 inactive lnvertArc procedure 1-181 control I-313 InvertOval procedure 1-178 window 1-46, 270 InvertPol y procedure 1-192 indicator of a dial 1-312 InvertRect procedure 1-177 lnfoScrap function 1-457 InvertRgn procedure I-186 InitAUPacks procedure 1-484 InvertRoundRect procedure 1-179 ///-269 Inside Macintosh invisible K control 1-316 dialog/alert item 1-406 kerning 1-152, 228 file icon 11-85 key codes 1-250 window 1-274 key-down event 1-244 IODone function 11-195 responding to 1-256 1/0 queue See driver 1/0 queue or file 1/0 key-up event I-244, 254 queue keyboard 1-33 1/0 request 11-97, 180 hardware Ill-29 lsATPOpen function 11-304 keyboard configuration 1-248 lsDialogEvent function 1-416 keyboard equivalent 1-343 lsMPPOpen function II-304 meta-chai:acter 1-348 item responding to I-356 dialog/alert 1-403 standard equivalents 1-53 menu I-341 keyboard event 1-244, 246 item list 1-403 event message 1-250 resource fonnat 1-427 responding to 1-256 item number keyboard touch See auto-key threshold dialog/alert I-406 KeyMap data type 1-260 menu 1-350 keypad 1-35 item type 1-404 hardware III-29 IUCompString function I-506 KeyRepThresh global variable 1-246 IUDatePString procedure 1-505 KeyThresh global variable 1-246 IUDateString procedure 1-504 KiIIControls procedure 1-321 IUEqua!String function 1-506 KillIO function IUGetlntl function 1-505 high-level 11-179 IUMaglDString function 1-507 low-level 11-187 IUMagString function 1-506 KillPicture procedure 1-190 IUMetric function 1-505 KillPoly procedure 1-191 IUSetlntl procedure 1-506 IUTimePString procedure 1-505 IUTimeString procedure 1-505 L IWM Ill-17 IWM global variable III-34 LAPAdrBlock data type 11-276 LAPCloseProtocol function 11-277 LAPOpenProtocol function 11-277 J LAPRdCancel function 11-279 LAPRead function 11-278 JFetch global variable 11-194 LAPWrite function 11-277 JIODone global variable 11-195 Launch procedure 11-60 job dialog 11-149 leading 1-228 job subrecord II-150 ligatures 1-501 journal code 1-262 line height 1-378 Journa!Flag global variable 1-261 Line procedure 1-171 journaling mechanism 1-261 LineTo procedure 1-170 Journa!Ref global variable 1-261 list separator 1-497 JStash global variable 11-195 Lo3Bytes global variable 1-85; 11-25 jump table 11-60 LoadNBP function 11-324 jump vector 11-194 LoadResource procedure 1-119 just-tempered scale 11-237 LoadScrap function 1-458 justification 1-376 LoadSeg procedure 11-60 setting 1-387 local coordinates 1-153 ///-2 70 Index local ID III-10 menu 1-341 LocalToGlobal procedure 1-193 defining your own I-362 location table 1-231 guidelines I-51 lock bit 11-25 resource format 1-364 locked block 1-76; 11-10 standard menus 1-54, 342 locked file 11-84 menu bar 1-341 locked volume II-80 resource format 1-365 locking a block 1-76; 11-41 menu definition procedure 1-344, 362 LodeScrap function 1-458 menu ID I-344 logarithmic functions 11-407 menu item 1-341 logical block II-119 blinking 1-361; 11-371 logical end-of-file 11-81 menu item number I-350 logical operations 1-471 menu list 1-345 logical size of a block 11-22 Menu Manager I-12, 339 LongMul procedure 1-472 routines 1-351 LookupName function 11-323 menu record 1-344 LoWord function 1-472 menu title I-341 ltGray global variable 1-162 MenuFlash global variable 1-361 LvllDT global variable 11-197 MenuHandle data type I-345 Lvl2DT global variable 11-198 MenuHook global variable 1-356 Menulnfo data type 1-345 MenuKey function I-356 M MenuList global variable 1-346 MenuPtr data type I-345 magnitude of a wave 11-223 MenuSelect function I-355 main event loop 1-16 meta-characters main segment 11-55 AppleTalk Manager 11-266, 320 MapPoly procedure 1-197 Menu Manager 1-346 MapPt procedure 1-196 MinStack global variable 11-17 MapRect procedure 1-196 MinusOne global variable I-85 MapRgn procedure 1-196 missing symbol 1-152, 220, 230 mark modal dialog box I-67, 400, 415 in a file 11-82 ModalDialog procedure 1-415 in a menu 1-347, 359 modeless dialog box 1-67, 400, 416 mark state 11-245 modes 1-28 master directory block 11-120 modifier flags 1-252 master pointer 1-75; 11-1 2 modifier keys 1-34, 246 allocation 11-22, 31 flags in event record 1-252 structure 11-25 MoreMasters procedure 11-31 MaxApp!Zone procedure 11-30 mounted volume 11-79 MaxMem function 11-38 MountVol function II-103 MBarEnable global variable 1-356, 446 mouse 1-36 MBarHook global variable 1-356 hardware III-25 MemError function 11-44 mouse-down event 1-244 memory block 1-73; II-10 responding to 1-255 memory management II-7 mouse scaling 11-372 introduction 1-71 mouse-scaling threshold 11-372 Memory Manager 1-12; 11-7 mouse-up event 1-244 routines II-27 responding to 1-255 memory organization 11-19 Move procedure 1-170 MemTop global variable II-19, 21, 44 MoveControl procedure I-325 III-2 71 Inside Macintosh MoveHHi procedure II-44 0 MovePortTo procedure 1-166 MoveTo procedure 1-170 ObscureCursor procedure 1-168 MoveWindow procedure 1-289 off-line volume II-80 MPP II-271 OftLine function 11-106 MPPClose function II-275 OffsetPoly procedure 1-191 MPPOpen function II-275 OffsetRect procedure 1-174 Munger function 1-468 OffsetRgn procedure 1-183 offset/width table 1-231 OfsetRgn procedure 1-18 3 N OldContent global variable 1-296 OldStructure global variable 1-296 Name-Binding Protocol 11-266 on-line volume 11-80 assembly language II-319 OneOne global variable 1-85 Pascal II-298 Open command 1-56 name lookup II-266 open device driver 11-176 names directory 11-266 open file 11-83 names information socket ll-266 Open function, high-level names table 11-266, 321 Device Manager 11-178 NBP See Name-Binding Protocol File Manager II-91 NBP tuple 11-266 Open function, low-level NBPConfirm function 11-301 Device Manager 11-184 NBPExtract function 11-300 File Manager 11-108 NBPLoad function 11-301 open permission 11-83 NBPLookup function 11-300 open routine NBPRegister function 11-299 of a desk accessory 1-445 NBPRemove function 11-301 of a driver Il-187 , 193 NBPUnJoad function 11-301 OpenATPSkt function 11-315 network event I-244; 11-275 OpenDeskAcc function 1-440 network number 11-265 OpenDriver function II-178 network-visible entity 11-265 OpenPicture function 1-189 New command 1-56 OpenPoly function 1-190 NewControl function 1-319 OpenPort procedure 1-163 NewDialog function 1-412 OpenResFile function 1-115 NewHandle function 1-76, 80; 11-32 OpenRF function newline character II-84 high-level II-91 newline mode 11-84 low-level II-109 NewMenu function 1-351 OpenRgn procedure 1-181 NewPtr function 1-75, 79; 11-36 OpenSkt function 11-311 NewRgn function 1-181 Operating System 1-9 NewString function 1-468 queues 11-372 NewWindow function 1-282 Operating System Event Manager 1-13; 11-65 node 11-263 routines Il-68 node ID 11-263 Operating System Utilities 1-13; 11-367 nonbreaking space 1-246 routines 11-374 nonrelocatable block 1-75; 11-10 OSErr data type 11-373 allocating 11-36 OSEventA vail function 11-70 releasing 11-36 OSType data type II-373 NoteAlert function 1-420 output driver 11-246 null event 1-245 overrun error See hardware overrun error or NumToString procedure 1-489 software overrun error owned resources 1-109 III-272 Index p PBControl function Il-186 PBCreate function 11-107 Pack2 See Disk Initialization Package PBDelete function 11-119 Pack3 See Standard File Package PBEject function 11-107 Pack4 See Floating-Point Arithmetic Package PBFlushFile function II-114 Pack5 See Transcendental Functions Package PBFlushVol function II-105 Pack6 See International Utilities Package PBGetEOF function II-112 Pack? See Binary-Decimal Conversion PBGetFinfo function 11-115 Package PBGetFPos function II-111 Package Manager I-12, 481 PBGetVInfo function 11-104 packages I-12, 483 PBGetVol function 11-104 PackBits procedure 1-470 PBKillIO function II-187 page rectangle 11-150 PBMountVol function 11-103 Page Setup command I-57 PBOffLine function II-106 PaintArc procedure I-180 PBOpen function PaintBehind procedure 1-297 Device Manager 11-184 PaintOne procedure I-296 File Manager 11-108 PaintOval procedure I-178 PBOpenRF function II-109 PaintPoly procedure I-192 PBRead function PaintRect procedure I-177 Device Manager II-185 PaintRgn procedure 1-186 File Manager 11-110 PaintRoundRect procedure I-179 PBRename function 11-118 PaintWhite global variable 1-297 PBRstFLock function 11-117 palette I-32 PBSetEOF function 11-112 pane I-49 PBSetFlnfo function 11-116 panel I-50 PBSetFLock function 11-116 paper rectangle 11-150 PBSetFPos function 11-111 ParamBlkType data type 11-98, 181 PBSetFVers function 11-117 ParamBlockRec data type 11-98, 181 PBSetVol function II-105 driver I/O queue entry II-191 PBStatus function 11-186 file I/O queue entry 11-124 PBUnmountVol function 11-106 parameter block 1-93; II-97, 180 PBWrite function parameter RAM II-369 Device Manager 11-185 default values 11-370 File Manager 11-110 routines II-380 pen characteristics I-150 ParamText procedure I-421 PenMode procedure 1-169 parity bit II-245 PenNormal procedure 1-170 parity error II-246 PenPat procedure I-170 ParmBlkPtr data type 11-98, 181 PenSize procedure 1-169 part code 1-315, 330 PenState data type 1-169 path reference number 11-83 period of a wave 11-223 PatHandle data type 1-473 phase of a wave cycle 11-223 PatPtr data type 1-473 physical end-of-file 11-81 pattern I-145 , 473 physical size of a block 11-23 Pattern data type I-146 PicComment procedure 1-189 pattern list 1-473 PicHandle data type 1-159 resource format 1-476 PicPtr data type 1-159 pattern transfer mode 1-157 picture 1-158 PBAllocate function 11-113 QuickDraw routines I-189 PBClose function utility routine I-475 Device Manager 11-184 picture comments I-159 File Manager Il-114 Picture data type I-159 lll-273 Inside Macintosh picture frame I-158 PrOpen procedure 11-157 PinRect function 1-293 PrOpenDoc function Il-159 pixel I-139, 143 PrOpenPage procedure II-159 Plotlcon procedure 1-473 proportional font 1-228 point (coordinate plane) 1-139 protocol 11-263 routines 1-193 protocol handler II-264 point (font size) 1-61, 153, 217 writing your own ll-324, 326 Point data type 1-139 protocol handler table 11-264 pointer (to memory) 1-75, 78 ; 11-11 PrPicFile procedure II-160 manipulation II-374 PrSetError procedure II- 16 1 type coercion I-79 PrSt!Dialog function II-158 pointer (on screen) 1-36, 37 See also cursor PrValidate function II- 158 polygon 1-159 PScrapStuff data type 1-457 routines 1-190 Pt2Rect procedure l-175 Polygon data type 1-159 PtlnRect fu nction l-175 PolyHandle data type 1-160 Pti nRgn function 1-185 PolyPtr data type 1-160 Ptr data type I-78 portBits of a grafPort 1-1 48 PtrAndHand function II-376 PortBUse global variable II-305 PtrToHand function Il-375 portRect of a grafPort 1-149 PtrToXHand function II-375 PortSize procedure I-165 PtrZone function 11-38 post an event 1-243 PtToAngle procedure I-175 PostEvent function 11-68 purge bit II-25 PrClose procedure 11-157 purge warning procedu re 11-23 PrCloseDoc procedure 11-1 60 purgeable block I-76; II-1 0, 41 PrClosePage procedure 11-160 PurgeMem procedure II-40 PrCtlCall procedure 11- 163 purging a block 1-76; II-14, 40 PrDrvrClose procedure II-163 PutScrap function 1-459 PrDrvrDCE function II-163 PrDrvrOpen procedure 11-163 PrDrvrVers function II-1 63 a PrError function 11-161 prime routine of a driver JI-187, 193 QDProcs data type 1- 197 Print command 1-57 QDProcsPtr data type 1- 197 print dialogs II-148 QE!em data type 11-373 print record 11-148 QElemPtr data type 11-373 PrintDefault procedure 11-158 QHdr data type 11-372 Printer Driver 1-13; 11-147, 162 QHdrPtr data type II-373 printer information subrecord 11-150 QTypes data type II-373 printer resource file 11-147 queue 11-373 PrintErr global variable 11-16 1 drive 11-127 printing grafPort II-147 driver 1/0 11-180, 19 1 Printing Manager 1-13; 11-145 file 110 II-97, 124 routines 11-157 manipulation ll-3 82 printing methods 11-153 vertical retrace II-350, 352 low-level IJ-164 volume-control-block II-125 private scraps 1-461 QuickDraw 1-11 , 135 PrJobDialog function 11- 158 communication with Font Manager I-224 PrJobMerge procedure Il-159 routines 1- 162 processor priority 11-196 Quit command 1-57 ProcPtr data type 1-78 ///-274 Index R Rename function high-level 11-96 radio button 1-312, 404 low-level 11-118 RAM III-1 7 ResErr global variable 1-116 RAM Serial Driver 1-13; II-246 ResError function l-116 advanced Control calls II-254 ResErrProc global variable J-116 Device Manager calls II-248 ResetAlrtStage procedure 1-423 routines 11-249 ResLoad global variable I-11 8 RAMBase global variable 1-87 resource 1-103 RAMSDClose procedure 11-250 within a resource 1-127 RAMSDOpen function 11-249 resource attributes 1-111 Random function 1-194 getting I-121 random number generator 1-194; II-407 setting 1- 122 randSeed global variable 1-163, 194 resource data 1-106 Read function, high-level resource file 1-105 Device Manager 11-178 attributes 1-126 File Manager 11-92 current 1-105, 116 Read function, low-level format 1-128 Device Manager 11-185 resource fork 1-105; II-8 1 File Manager 11-110 resource header 1-1 28 ReadDateTime function 11-378 resource ID 1-108 ReadPacket function 11-327 of fonts I-234 ReadRest function 11-327 of owned resources I-109 read/write permission Il-83 Resource Manager 1-9, 101 RealFont function 1-223 routines I-11 3 reallocating a block 1-76; 11-14 resource map 1-106 ReallocHandle procedure II-35 resource name 1-110 RecoverHandle function II-35 resource reference 1-110 Rect data type 1-141 format I-130 rectangle 1-140 resource specification 1-103, 107 routines 1-174 resource type 1-103 RectlnRgn function 1-185 list 1-107 RectRgn procedure 1-183 response BDS 11-288, 314 reference number of a resource file 1-105 ResrvMem procedure 11-39 reference value Restart procedure Il-385 control 1-316 RestoreA5 procedure 11-386 window 1-274 ResType data type 1-107 region 1-141 result code I-116; 11-27, 374 routines I-181 assembly language 1-94 Region data type 1-142 list III-205 register-based routines 1-90, 93 resume procedure 1-411 ; 11-35 8 register-saving conventions I-94 ResumeProc global variable 1-411 RegisterName function II-322 RetransType data type 11-298 relative handle 11-24 retry count 11-266 release timer 11-270 retry interval 11-266 ReleaseResource procedure 1-120 Revert to Saved command 1-57 relocatable block 1-75; II-10 RgnHandle data type 1-142 allocating 11-32 RgnPtr data type 1-142 releasing 11-33 RmveResource procedure J-124 RelRspCB function 11-319 RndSeed global variable 1-195 RelTCB function II-319 ROM III-18 RemoveNarne function 11-324 III-275 Inside Macintosh ROM Serial Driver 1-13; 11-246 ScrHRes global variable 1-473 Device Manager calls 11-248 ScrnBase global variable 11-19, 21 routines 11-250 scroll bar 1-47, 312 ROMBase global variable 1-87; 11-383; III-18 updating 1-291 ROMFontO global variable I-233 ScrollRect procedure 1-187 routine selector 1-483 ScrVRes global variable 1-473 routing table II-265 SdVolume global variable 11-232 Routing Table Maintenance Protocol II-265 Secs2Date procedure 11-380 row width 1-143 sector 11-211 RsrcZonelnit procedure 1-114 SectRect function 1-175 RstFilLock function SectRgn procedure 1-184 high-level II-96 segment II-55 low-level II-117 Segment Loader 1-12; II-53 RstFLock function 11-96 routines ll-57 RTMP II-265 selection range 1-375 RTMP socket II-265 SelectWindow procedure 1-284 RTMP stub II-265 SeIIText procedure 1-422 SendBehind procedure 1-286 SendRequest function 11-316 $ SendResponse function 11-317 sequence number of a datagram 11-266 sample program 1-13 SerClrBrk function 11-253 SANE II-405 SerGetBuf function II-253 Save As command 1-57 SerHShake function 11-251 Save command 1-57 serial communication II-245 SaveOld procedure 1-296 hardware III-22 SaveUpdate global variable 1-297 Serial Communications Controller ITI-22 SaveVi sRgn global variable 1-293 serial data 11-245 ScalePt procedure 1-195 Serial Drivers 1-13; 11-243 scaling t::ictors 1-218 advanced Control calls 11-254 sec m-22 Device Manager calls II-248 sec inte rrupts 11-198 routines 11-249 SCCRd global variable 11-199; III-25 SerReset function 11-250 SCCWr global variable 11-199; III-25 SerSetBrk function 11-252 scrap SerSetBuf function 11-251 between applications 1-453 SerShk data type 11-252 in TextEdit 1-373, 388 SerStaRec data type 11-253 scrap file 1-453 SerStatus function 11-253 Scrap Manager 1-12, 451 SetAppBase procedure 11-28 routines 1-457 SetApplBase procedure 11-28 ScrapCount global variable 1-457 SetApplLimit procedure 11-30 ScrapHandle global variable 1-457 SetClikLoop procedure J-390 ScrapName global variable 1-457 SetCli p procedure 1-166 ScrapSize global variable 1-457 SetCRefCon procedure 1-327 ScrapState global variable 1-457 SetCTitle procedure I-321 ScrapStuff data type 1-457 SetCtlAction procedure 1-328 Scratch8 global variable 1-85 SetCtlMax procedure 1-327 Scratch20 global variable 1-85 SetCtlMin procedure 1-326 ScrDmpEnb global variable 1-258 SetCtlValue procedure 1-326 screen buffer III-18, 19 SetCursor procedure 1-167 screenBits global variable 1-145, 163 SetDAFont procedure I-412 ScreenRes procedure 1-473 SetDateTime function 11-379 Ill-276 Index SetDitem procedure 1-421 SetTagBuffer function II-214 SetEmptyRgn procedure 1-183 SetTime procedure 11-380 SetEOF function SetTrapAddress procedure II-384 high-level II-93 SetUpA5 procedure 11-386 low-level 11-112 SetVol function SetEventMask procedure 11-70 high-level II-89 SetFilelnfo function low-level 11-105 high-level II-95 SetWindowPic procedure 1-293 low-level II-116 SetWordBreak procedure 1-390 SetFilLock function SetWRefCon procedure 1-293 high-level II-95 SetWTitle procedure I-284 low-level 11-116 SetZone procedure 11-31 SetFilType function 11-117 SEvtEnb global variable 1-443 SetFinfo function 11-95 SFGetFile procedure 1-523 SetFLock function 11-95 SFPGetFile procedure 1-526 SetFontLock procedure 1-223 SFPPutFile procedure I-523 SetFPos function SFPutFile procedure 1-519 high-level II-93 SFReply data type I-519 low-level II-111 SFSaveDisk global variable 1-519 SetGrowZone procedure 11-42 SFTypeList data type 1-523 SetHandleSize procedure II-34 ShieldCursor procedure 1-474 Setltem procedure 1-357 ShowControl procedure 1-322 Setltemlcon procedure 1-359 ShowCursor procedure I-168 SetltemMark procedure 1-359 ShowHide procedure I-285 SetltemStyle procedure 1-360 ShowPen procedure I-168 SetlText procedure 1-422 ShowWindow procedure I-285 Setltmlcon procedure 1-359 signature III-9 SetitmMark procedure 1-359 SignedByte data type 1-78 SetltmStyle procedure 1-360 size SetMaxCtl procedure 1-327 of parameters 1-90 SetMenuBar procedure I-355 of variables 1-85 SetMenuFlash procedure 1-361 size box I-287 See also grow region SetMFlash procedure I-361 size correction 11-24 SetMinCtl procedure I-326 Size data type 11-18 SetOrigin procedure l-166 SizeControl procedure 1-326 SetPBits procedure 1-165 SizeResource function 1-1 21 SetPenState procedure 1-169 SizeRsrc function 1-121 SetPort procedure 1-165 SizeWindow procedure 1-290 SetPortBits procedure I-165 SlopeFromAngle function 1-475 SetPt procedure I-193 socket 11-265 SetPtrSize procedure II-37 socket client II-265 SetRecRgn procedure I-183 socket listener 11-265 SetRect procedure 1-174 writing your own JI-324, 329 SetRectRgn procedure 1-183 socket number II-265 SetResAttrs procedure 1-122 socket table 11-265 SetResFileAttrs procedure 1-127 software overrun error II-246 SetReslnfo procedure I-122 sound buffer II-233; III-18, 21 SetResLoad procedure 1-11 8 Sound Driver 1-13; II-221 SetResPurge procedure 1-126 hardware II-233 SetSoundVol procedure 11-233 routines 11-231 SetStdProcs procedure 1-198 sound generator 11-223; III-20 SetString procedure I-468 sound procedure 1-409, 411, 425 lll-277 Inside Macintosh SoundBase global variable Ill-21 StdRgn procedure 1-199 SoundDone function 11-232 StdRRect procedure 1-198 SoundLevel global variable II-234 StdText procedure 1-198 SoundPtr global variable II-227 StdTxMeas function 1-199 source transfer mode 1-157 StillDown function 1-259 space state II-246 stop bit 11-245 SpaceExtra procedure 1-172 StopAlert function 1-419 SPAlarm global variable See parameter RAM StopSound procedure 11-232 SPATalkA global variable See parameter Str32 data type 11-298 RAM Str255 data type 1-78 SPATalkB global variable See parameter string comparison 1-501, 506; 11-376 RAM string list I-468 SPClikCaret global variable See parameter resource format 1-476 RAM string manipulation 1-468 SPConfig global variable II-305 StringHandle data type 1-78 speaker volume 11-232, 371 StringPtr data type I-78 SPFont global variable See parameter RAM StringToNum procedure I-490 SPKbd global variable See parameter RAM StringWidth function 1-173 split bar 1-49 structure region ofa window 1-271 SPMisc2 global variable See parameter RAM StuffHex procedure 1-195 spool printing 11-151, 153 style See character style SPortSel data type II-249 Style data type 1-152 SPPortA global variable See parameter RAM style dialog II-149 SPPortB global variable See parameter RAM Style menu 1-61 SPPrint global variable See parameter RAM Styleltem data type 1-152 SPYalid global variable See parameter RAM SubPt procedure 1-193 SPVolCtl global variable See parameter RAM SWSynthPtr data type 11-225 square-wave synthesizer II-223, 225 SWSynthRec data type II-225 stack 1-73; 11-17 synchronous execution stack-based routines 1-90 AppleTalk Manager 11-273 stack frame 1-96; 11-17 Device Manager II-180 StageList data type 1-424 File Manager 11-97 stages of an alert 1-409 synthesizer buffer 11-225 Standard File Package 1-12, 515 SysBeep procedure ll-385 routines 1-519 SysEdit function 1-441 start bit II-245 SysError procedure 11-362 StartSound procedure II-231 SysEvtMask global variable II-70 Stash function 11-195 SysMap global variable 1-114 Status function SysMapHndl global variable 1-114 high-level 11-179 SysParam global variable 11-369 low-level 11-186 SysParmType data type II-370 status information 11-176 SysPPtr data type 11-370 status routine of a driver 11-187, 194 SysResName global variable 1-114 StdArc procedure 1-199 system error alert 11-357 StdBits procedure 1-199 system error alert table 11-357, 359 StdComment procedure 1-199 System Error Handler 1-13; 11-18, 355 StdGetPic procedure 1-200 routine II-362 StdLine procedure 1-198 system error ID II-357 StdOval procedure I-199 system event mask 1-254; II-70 StdPoly procedure 1-199 system font 1-219 StdPutPic procedure 1-200 system font size 1-219 StdRect procedure 1-198 system heap 1-74; II-9 ///-278 Index system resource 1-103 text streaming 11-165 system resource file 1-103 TextBox procedure 1-388 system startup information 11-120 TextEdit 1-12, 371 system traps III-215 routines 1-383 system window 1-270, 438 scrap 1-373, 388 SystemClick procedure 1-441 TextFace procedure I-171 SystemEdit function 1-441 TextFont procedure 1-171 SystemEvent function 1-442 TextMode procedure 1-171 SystemMenu procedure 1-443 TextSize procedure I-171 SystemTask procedure 1-442, 444; 11-189 TextWidth function 1-173 SystemZone function 11-32 TheMenu global variable 1-357 SysZone global variable II-19, 21, 32 thePort global variable 1-162, 165 TheZone global variable 11-31 thousands separator I-497 T THPrint data type II-149 thumb 1-312 tag byte 11-24 THz data type 11-22 TEActivate procedure 1-385 tick I-246 TECalText procedure 1-390 TickCount function 1-260 TEC!ick procedure 1-384 Ticks global variable I-260; II-198 TECopy procedure 1-386 Time global variable 11-198, 369, 378 TECut procedure 1-385 time operations 11-377 TEDeactivate procedure 1-385 ToExtFS global variable II-128 TEDelete procedure 1-387 toggled command 1-53, 357 TEDispose procedure 1-383 Tone data type II-225 TEDoText global variable 1-391 Tones data type 11-225 TEFromScrap function 1-389 Toolbox 1-9 TEGetScrapLen function 1-389 Toolbox Event Manager 1-11, 241 TEGetText function 1-384 routines 1-257 TEHandle data type 1-374 Toolbox Utilities 1-12, 465 TEldle procedure 1-384 routines 1-467 TElnit procedure 1-383 ToolScratch global variable I-85 TElnsert procedure 1-387 TopMapHndl global variable 1-115 TEKey procedure 1-385 TopMem function II-44 TENew function 1-383 TPPrint data type 11-149 TEPaste procedure 1-386 TPPrPort data type 11-147 TEPtr data type 1-374 TPrlnfo data type 11-150 TERec data type 1-377 TPrint data type II-149 TERecal global variable 1-391 TPrJob data type 11-151 TEScrapHandle function 1-389 TPrPort data type Il-147 TEScroll procedure 1-388 TPrStatus data type 11-161 TEScrpHandle global variable 1-389 TPrStl data type II-152 TEScrpLength global variable 1-389 TPrXInfo data type II-152 TESetJust procedure 1-387 track on a disk 11-211 TESetScrapLen procedure 1-390 TrackControl function 1-323 TESetSelect procedure 1-385 TrackGoAway function 1-288 TESetText procedure 1-383 transaction 11-266 TestControl function 1-325 transaction ID 11-266 TEToScrap function 1-389 transaction release II-270 TEUpdate procedure 1-387 transaction request II-266 text characteristics 1-151 transaction response 11-266 text in a dialog/alert 1-404, 408 III-279 Inside Macintosh Transcendental Functions Package 1-13; UTableBase global variable II-192 11-403, 407 Utilities, Operating System 1-13; 11-307 transfer mode 1-156 routines 11-374 trap dispatch table 1-87 Utilities, Toolbox 1-12, 465 routines 11-383 routines 1-467 trap dispatcher I-89 trap macro I-88, 90 list III-215 v trap number I-89, 384 trap word 1-88 validity status 11-370 TRel See transaction release ValidRect procedure 1-292 TReq See transaction request ValidRgn procedure I-292 TResp See transaction response variation code trigonometric functions II-407 control I-328 type coercion I-79 window 1-298 type size See font size VBL interrupt See vertical blanking interrupt VBL task II-350 VBLQueue global variable II-352 u VBLTask data type 11-350 VCB data type 11-125 Undo command 1-59 VCBQHdr global variable Il-126 unimplemented instruction 1-88 vector Il-196 UnionRect procedure I-175 vector table II-196 UnionRgn procedure 1-184 Versatile Interface Adapter III-39 UniqueID function 1-121 version data III-10 unit number 11-191 version number of a file 11-81 unit table 11-191 vertical blanking interrupt 11-349; 111-1 8 UnloadNBP function 11-324 vertical blanking interval III-1 8 UnloadScrap function I-458 vertical retrace interrupt I-13; II-349 UnloadSeg procedure 11-59 Vertical Retrace Manager I-13; II-347 unlocked block I-76 ; 11-10 routines 11-351 unlocking a block I-76; 11-41 vertical retrace queue II-350, 352 UnlodeScrap function I-458 VHSelectdata type I-139 unmounted volume II-79 VIA III-39 UnmountVol function VIA global variable I-198; III-39 high-level 11-90 VIA interrupts II-197; III-3 8, 41 low-level II-106 videointerface III-18 UnpackBits procedure 1-470 view rectangle I-374 unpurgeable block 1-76; 11-10, 42 Vlnstall function 11-351 update event 1-244, 278 visible event message 1-252 control 1-316 update region of a window 1-272 window I-274 maintenance I-291 visRgn of a grafPort 1-149 UpdateResFile procedure 1-125 volume (on a disk) 11-79 UprString procedure 11-377 volume (speaker) 11-232, 371 use type 11-305 volume allocation block map II-122 user bytes 11-266 volume attributes 11-121 user interface guidelines 1-23 volume buffer 11-79 User Interface Toolbox 1-9 volume control block 11-125 UseResFile procedure I-117 volume-control-block queue II-125 userltem in a dialog 1-404, 405 volume index 11-102 installing I-421 volume information II-121 ///-280 Index volume name II-79 WriteParam function 11-382 volume reference number 11-79 WriteResource procedure 1-125 VRemove function 11-351 x w XorRgn procedure 1-185 WaitMouseUp function 1-259 Wave data type 11-227 waveform 11-223 y waveform description II-224 wavelength 11-223 WavePtr data type II-227 z white global variable 1-162 window 1-44, 269 ZeroScrap function 1-458 closing 1-45, 283 zone defining your own 1-297 AppleTalk Manager II-266 moving 1-46, 289 Memory Manager See heap zone opening 1-45, 282 Zone data type II-22 resource format 1-302 zone header 11-22 sizing 1-47, 289 zone pointer 11-22 splitting 1-49 zone record II-22 window class 1-274, 276 zone trailer 11-22 window definition function 1-272, 298 window definition ID 1-273, 298 window frame 1-271 window list 1-274, 277 Window Manager 1- 11, 267 routines 1-28 1 Window Manager port 1-27 1, 282 window pointer 1-275 window record 1-274, 276 window template 1-274 resource format 1-302 WindowList global variable 1-255, 277 WindowPeek data type I-275 WindowPtr data type 1-275 Window Record data type 1-276 WMgrPort global variable I-282 word 1-42 in TextEdit 1-373 word break routine 1-380 word wraparound 1-373 write data structure II-306 Write function, high-level Device Manager 11-179 File Manager 11-92 Write function, low-level Device Manager 11-185 File Manager 11-110 WriteDDP function II-312 WriteLAP function 11-307 1//-281 Inside Macintosh Welcome to the world of programming for the Macintosh®. No other personal computer has been as eJ;lthusiastically received by the programming community, as the large-and growing-body of Macintosh software attests. Inside Macintosh provides the guidelines and technical information that you'll need to develop Macintosh programs, but many other resources can help speed and simplify your software development efforts. Development Languages You won't have to look far to find a development language that suits your specific requirements. A growing family of Macintosh languages will serve your development needs whether your expertise is in Pascal, C, Assembler, FORTH, FORTRAN, COBOL, BASIC, Lisp, Modula-2, or one of many others. And the information in Inside Macintosh can be applied to any of the Macintosh languages. The Certified Developer Program If your primary business is developing software products for commercial markets, we strongly suggest that you investigate the Apple Certified Developer Program. This program helps developers produce and bring Macintosh products to market by providing them with support programs, services, and information. Among them are •Technical Support: Apple's Developer Technical Support Group offers fast answers by way of AppleLink® or MCI electronic mail. • Macintosh Technical Notes: This is a bimonthly package of supplemental technical information. • AppleLink: Through this electronic service, you can get answers to your technical questions and current information on Apple and third-party products and programs. • Certified Developer Mailings: These monthly mailings keep you informed about Apple's products, development tools, and technical and company directions. • The Information Exchange: This information, available in printed and HyperCard® stack form, lists company-sponsored programs and services available to you and your company. • Outside Apple: This monthly newsletter informs you of developer-oriented Apple groups, programs, and events. You must meet certain criteria to get Certified Developer status. You can get an information package and application by writing to Developer Programs Apple Computer, Inc. 20525 Mariani Avenue, MIS 51-W Cupertino, CA 95014 APDA The Apple Programmer's and Developer's Association, APDA™, provides technical documentation and products for all programmers and developers who work on Apple equipment. It provides material that is unavailable elsewhere (including preliminary documentation of new Apple products). APDA also sells compilers and other tools from both Apple and third-party sources. For information on joining, write to APDA 290 SW 43rd Street Renton, WA 98055 (206) 251-6548 Technical Notes Published bimonthly by Developer Technical Support, these notes answer frequently asked questions through examples and sample code and provide updates, additions, and corrections to the Inside Macintosh books. They are available through the Certified Developer Program, APDA, and major electronic information services. Apple®Inside Macintosh > $19-95 FPT USA The Official Volume ill Publication from Apple Computer, Inc. \X-Titcen by the people at Apple Computer, Inside Macintosh is the definitive source of information for programmers writing application programs, desk accessories, device drivers, and otl1er software for any of the computers in the Apple Macintosh®family. It includes: • Guidelines for designing a user interface that conforms to the Macintosh standard. • Descriptions of more tl1an 1,200 ROM- and disk-based routines. • Adescription of the Macintosh hardware. Inside Macintosh is your guide to creating software for the Macintosh, whatever programming language you use. It describes tl1e Pascal interfaces to the routines and, wherever applicable, gives special information for programming in assembly language. (If you're using a high-level language other than Pascal, your development system documentation should teUyou how to apply the information in Inside Macintosh.) Atypical chapter describes a related set of routines, such as the Window Manager, and provides: • Keyconcepts and backgrow1d information. • Hints on which routines you need to learn about and how they fit into your program. • Adetailed description ofeach routine. Inside Macintosh consists of sLx volumes.This volume, Volume III, contains: • Adiscussion of your program's interface with the Macintosh Finder.'" • Adescription of the Macintosh 128Kand 512K computers. • Summaries ofall the Managers and otl1er software described in volumes I, II, and Ill. Volume I contains important introductory material and describes the QuickDraw graphics package and important Managers such as the Resource, Font, and Menu Managers.Volume II complements Volume I in describing the Managers that perform such basic routines as file and device 110, memory management, and interrupt handling.Volume IV discusses the changes introduced bytl1e Macintosh 512K Enhanced and Macintosh Plus computers, including the Hierarchical File System and tl1e SCSI port.Volume Vdiscusses tl1e changes inu·oduced by the Macintosh SE and Macintosh II computers, including color, NuBus'" slots, and the Apple Desktop Bus:· Inside Macintosh X-Ref provides a single index to Inside Macintosh and otl1er Macintosh tedmical books. About the cover: This design represent5 a new look for the original edition of Inside Macintosh, Volume ffl, and tl1e other books in the Apple Technical Library. The contents have not been changed. Printed in U.SA. 51995 Apple Computer, Inc. 20525 Mariani Avenue Cupertino, CA 95014 (408) 996-1010 1lX 171-576 9 780201 17 7336 Addison-Wesley Publishing Company, Inc. ISBN 0-201-17733-1