Important: The information in this document is obsolete and should not be used for new development.
Inserting the ROM Resource Map
Many system resources are stored in ROM. System software calls theInitResourcesfunction during system startup, and the Resource Manager creates a special heap zone in the system heap and builds a resource map that points to the ROM resources.The Resource Manager normally searches ROM resources only when you use the
RGetResourcefunction to get a handle to the resource, and even then only after it searches the System file's resource fork. To search for a resource in ROM before searching the System file's resource fork, your application must first alter the resource search order by inserting the ROM resource map in front of the System file's resource map.When the value of the global variable
RomMapInsertisTRUE, the Resource Manager inserts the ROM resource map before the System file's resource map for the next call only. When the value ofRomMapInsertisTRUE, the adjacent variableTmpResLoaddetermines whether the value of the global variableResLoadis consideredTRUEorFALSE, overriding the actual value ofResLoadfor the next call only. The values of theRomMapInsertandTmpResLoadvariables are cleared after each call to a Resource Manager routine.The
RGetResourcefunction first callsGetResource. IfGetResourcecannot locate the requested resource in the resource chain,RGetResourcesetsRomMapInserttoTRUE, then callsGetResourceagain.To set the
RomMapInsertandTmpResLoadvariables in tandem yourself, you can use two global constants. Set the system global variableRomMapInsertto the global constantmapTrueto insert the ROM resource map withSetResLoad(TRUE). SetRomMapInsertto the global constantmapFalseto insert the ROM resource map withSetResLoad(FALSE).There is no real resource fork associated with the ROM resources; the ROM resource map has a path number of 1 (an illegal path reference number). There are two ways to determine whether a handle references a ROM resource. First, you can set up
RomMapInsertandTmpResLoadand callHomeResFile; if 1 is returned, the handle is to a ROM resource. Second, you can dereference the handle and check whether the master pointer points to ROM by comparing it to the global variableROMBase.