mac-rom/Internal/Asm/ResourceMgrPriv.a
Elliot Nunn 0ba83392d4 Bring in CubeE sources
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included.

The Tools directory, containing mostly junk, is also excluded.
2017-09-20 18:04:16 +08:00

413 lines
15 KiB
Plaintext

;
; File: ResourceMgrPriv.a
;
; Contains: private equates for the Resource Manager
;
; Copyright: © 1983-1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM9> 5/27/93 SAM Added definition for mapForceSysHeap.
; <SM8> 3/31/93 SAM Changed kDeanBit from 2 (which was conflicting with
; systemEnabledBit) to bit 1.
; <SM7> 12/4/92 RB Added kFakeResourceOverrideMapRefNum
; <SM6> 7/27/92 FM Add elements to the ResourceMgr stack frame for use in StdEntry
; and StdExit to implement resource overrides.
; <4+> 6/14/92 CS Rollin changes from Reality :
; <14> 5/14/92 DTY #000000: Add interface for CloseResFileUnderSystemMap.
; <SM4> 4/24/92 CSS Integrated Reality changes: <13>
; <13> 3/30/92 DTY #1025140,<FM>: Add kAllOverrideAttributesMask and
; kAllButOverrideAttributesMask.
; <SM3> 4/24/92 PN Change ioQElSize to ioHQElSize.
; <SM2> 4/14/92 stb extend the standard stack frame to include the decompressor
; defproc handle
; <12> 1/30/92 DTY Add equates for preventFileFromBeingClosedBit and
; preventFileFromBeingClosedMask.
; <11> 12/17/91 DTY Add selector for _ResolveIDConflicts.
; <10> 12/6/91 DTY Add selector for _OpenResFileUnderSystemMap.
; <9> 11/5/91 DTY Add selectors for MakeOverrideMap, SetOverrideAttributes,
; GetOverrideAttributes, and SetScanOverride routines. Change
; GetMap and IsThisASystemResourceMap to negative selectors since
; these are really private routines. Switch mask values for
; kDontCountOrIndexDuplicates and kTwoDeep to match the bit
; definitions.
; <8> 11/1/91 DTY Add macro for _IsThisASystemResourceMap.
; <7> 10/23/91 DTY Add macros for _GetOverrideMap and _GetMaps, which are new
; selectors off of _ResourceDispatch.
; <6> 10/15/91 DTY Define yet another bit, twoDeepBit, which causes one deep calls
; to search the next lower map if a resource isnÕt found in the
; current map. This search recurses if the lower map also has
; this bit set.
; <5> 10/15/91 DTY Add mapInsertedBit & dontCountOrIndexDuplicatesBit. Resource
; maps with mapInsertedBit set causes UseResFile to back up to the
; first map with this bit set. Maps with
; dontCountOrIndexDuplicatesBit set 1) will not consider duplicate
; resources in different maps during CountResources and
; GetIndResource calls and 2) contiguous maps with this bit set
; are considered one file (one deep calls will use the n-deep
; calls).
; <4> 1/30/91 gbm sab, #38: Change the Ôalready including this fileÕ variable to
; all uppercase (for security reasons)
; <3> 10/24/90 dba add new attributes byte
; <1.1> 8/30/89 dba added some missing equates
; <1.0> 8/18/89 dba created from equates in ResourceMgr.a
;
IF &TYPE('__INCLUDINGRESOURCEMGRPRIV__') = 'UNDEFINED' THEN
__INCLUDINGRESOURCEMGRPRIV__ SET 1
;
; These selectors are for the SystemÕs enjoyment only, and shouldnÕt be made public.
;
selectCloseResFileUnderSystemMap equ -4
selectResolveIDConflicts equ -3
selectOpenResFileUnderSystemMap equ -2
selectIsThisASystemResourceMap equ -1
selectGetMap equ 0
Macro
_CloseResFileUnderSystemMap
DoDispatch _ResourceDispatch,selectCloseResFileUnderSystemMap
EndM
Macro
_ResolveIDConflicts
DoDispatch _ResourceDispatch,selectResolveIDConflicts
EndM
Macro
_OpenResFileUnderSystemMap
DoDispatch _ResourceDispatch,selectOpenResFileUnderSystemMap
EndM
Macro
_IsThisASystemResourceMap
DoDispatch _ResourceDispatch,selectIsThisASystemResourceMap
EndM
Macro
_GetMap
DoDispatch _ResourceDispatch,selectGetMap
EndM
;
; These declarations should be moved into Traps.a if we ever make it public.
;
kDecompressionPasswordMask equ 1
kOverrideNextMapMask equ 2
kDontCountOrIndexDuplicatesMask equ 4
kTwoDeepMask equ 8
kPreventFileFromBeingClosedMask equ 16
kAllOverrideAttributesMask equ kOverrideNextMapMask + \
kDontCountOrIndexDuplicatesMask + \
kTwoDeepMask + \
kPreventFileFromBeingClosedMask
kAllButOverrideAttributesMask equ 255 - kAllOverrideAttributesMask
selectMakeOverrideMap equ 4
selectInsertOverrideMap equ 5
selectGetOverrideMap equ 6
selectSetScanOverride equ 7
selectGetOverrideAttributes equ 8
selectSetOverrideAttributes equ 9
Macro
_MakeOverrideMap
DoDispatch _ResourceDispatch,selectMakeOverrideMap
EndM
Macro
_InsertOverrideMap
DoDispatch _ResourceDispatch,selectInsertOverrideMap
EndM
Macro
_GetOverrideMap
DoDispatch _ResourceDispatch,selectGetOverrideMap
EndM
Macro
_SetScanOverride
DoDispatch _ResourceDispatch,selectSetScanOverride
EndM
Macro
_GetOverrideAttributes
DoDispatch _ResourceDispatch,selectGetOverrideAttributes
EndM
Macro
_SetOverrideAttributes
DoDispatch _ResourceDispatch,selectSetOverrideAttributes
EndM
;_______________________________________________________________________________
;
; Resource Fork format
;_______________________________________________________________________________
;
; The resource fork contains all the resource data, the resource map,
; and several special data objects in fixed locations. These data objects
; are normally accessed only by the Finder.
;
; --------------------------
; Picture of a Resource Fork
; --------------------------
;
; 0-------------------> ---------------------------------
; ! Resource Header !
; 16------------------> ! Directory copy !
; 128-----------------> ! ....other user data.... !
; ! ... !
; ResDataOffset-------> ! Resource Data !
; ! ... !
; ! !
; ResMapOffset--------> ! Resource Map !
; ! ... !
; ---------------------------------
;
; (Note ResDataOffset+DataSize=ResMapOffset,
; ResMapOffset+MapSize=EOF.)
;
;_______________________________________________________________________________
;_______________________________________________________________________________
;
; Resource header is defined as follows:
resDataOffset EQU 0 ; 4 byte offset to resource data in the file
resMapOffset EQU resDataOffset+4 ; 4 byte offset to resource map in the file
dataSize EQU resMapOffset+4 ; 4 byte data size
mapSize EQU dataSize+4 ; 4 byte map size
hdrSize EQU mapSize+4
; After resource header, remaining block has the following info by convention:
dirCopy EQU hdrSize ; Copy of directory entry, truncated to 112 bytes
userData EQU dirCopy+112 ; User data starts here and continues
; up to ResDataOffset. CreateResFile
; allocates 128 bytes for userData.
dataFirstRes EQU userData+128 ; ResDataOffset usually points here.
;_______________________________________________________________________________
;
; Resource Data format
;_______________________________________________________________________________
;
; Each resource has a four-byte length, followed by the data. The data
; is packed initially, and UpdateResFile packs the data if fragmented
; by RmveResource, ChangedResData, and UpdateResFile calls.
;_______________________________________________________________________________
;_______________________________________________________________________________
;
; Resource Map format
;_______________________________________________________________________________
;
; The Resource Map contains references to resources either in the current
; resource file or in Sys.rsrc. These references include the type, ID,
; and/or names of the resources, their locations in the data section of the
; resource fork, and special attributes of each resource.
;
; --------------------------
; Picture of a Resource Map
; --------------------------
;
; 0-------------------> ---------------------------------
; ! (Copy of Resource Hdr) !
; 16------------------> ! MNext !
; ! MRefNum !
; ! MAttr !
; ! MTypes !
; ! MNames !
; MTypes--------------> ! TypeCount !
; ! TypeA !
; ! CountA !
; ! OffsetA !
; ! TypeB !
; ! CountB !
; ! OffsetB !
; ! ... !
; MTypes+OffsetA-----> ! IDA1 !
; ! NameOffA1 !
; ! LocationA1 !
; ! HandleA1 !
; ! IDA2 !
; ! NameOffA2 !
; ! LocationA2 !
; ! HandleA2 !
; ! ... !
; MTypes+OffsetB-----> ! IDB1 !
; ! NameOffB1 !
; ! LocationB1 !
; ! HandleB1 !
; ! ... !
; MNames-------------> ! <length> !
; ! "Ascii String" !
; MNames+NameOff2----> ! <length2> !
; ! "Another String" !
; ! ... !
; ---------------------------------
;
; (Note: MTypes is always the same--right after
; the resource map header. )
;
;_______________________________________________________________________________
;
; The resource map is defined as follows:
;
; A copy of resource header precedes the other resource map info.
mNext EQU hdrSize ; Handle to next map
mRefNum EQU mNext+4 ; Map file reference number
mAttr EQU mRefNum+2 ; Map attributes word (high byte only used)
mInMemoryAttr equ mAttr+1 ; Attributes for use in memory only <3>
mTypes EQU mAttr+2 ; Type offset in map (64K max offset)
mNames EQU mTypes+2 ; Name offset in map (64K max offset)
; bits in mInMemoryAttr
decompressionPasswordBit equ 0 ; set this to search for dcmps in this map <3>
overrideNextMapBit equ 1 ; set this bit to recursively override resources in the next lower map when _UseResFile is called on the lower map <6>
dontCountOrIndexDuplicatesBit equ 2 ; set this bit to not count or index through duplicate resource types and IDs <5>
twoDeepBit equ 3 ; set this bit to recursively look in the current map and the next map on one deep calls <6>
preventFileFromBeingClosedBit equ 4 ; set this bit to prevent a resource file from being closed. <12>
; bits in mAttr
mapForceSysHeap equ 0 ; set this bit to force all map resources to load in SysHeap <SM9>
;_______________________________________________________________________________
;
; Type Block:
typeCount EQU 0 ; TypeCount(A3) gives number of types
; Offsets into a type entry:
tType EQU 0 ; Type of resources
tCount EQU tType+4 ; 2 byte count, zero based
tOffset EQU tCount+2 ; 2 byte offset
tSize EQU tOffset+2 ; Type entry size
typeShift EQU 3 ; log2 TSize.
;_______________________________________________________________________________
;
; Offsets into a resource entry:
rID EQU 0 ; ID of the resource
rNameOff EQU rID+2 ; name offset of the resource
rAttr EQU rNameOff+2 ; attribute byte (high byte of locn)
rLocn EQU rAttr ; location of the resource in source file
rHndl EQU rLocn+4 ; handle of the resource
refID EQU rHndl ; if reference, ID of refÕd resource
refNameOff EQU refID+2 ; if reference, NameOff of refÕd resource
reSize EQU rHndl+4 ; resource entry size
;_______________________________________________________________________________
;
; Stack frame definition
ioStkFrame EQU -ioHQElSize ; stack frame is ioHQElSize long
rMgrStack EQU ioStkFrame ; Resource mgr stack frame = IOStkFrame
kDeanBit equ 1 ; <SM8><53> This bit in BrianBits will mark whether or not this call to CheckLoad allocates the master pointer
kBrianBits equ $B20 ; <53> We never define this in an interface file
kInitialEntryCount equ 30 ; Make space for 30 resources at first
; Cache flag bits
kCacheIsOneDeepBit equ 0 ; Cache was formed from a one deep call
kCacheHasROMResourcesBit equ 1 ; <34> Cache was formed when ROMMapInsert was set.
kCacheHasOverridesBit equ 2 ; <35> Cache was formed when emScanOverrides was on
; Cache flag masks
kCacheIsOneDeepMask equ 1 ; <34>
kCacheHasROMResourcesMask equ 2 ; <34>
kCacheHasOverridesMask equ 4 ; <35>
; Cache offsets
kCacheFlags equ 0 ; Flags for cache
kCachedMap equ 2 ; Resources cached from this resource map
kResourceType equ 4 ; Resource type in cache
kResourceCount equ 8 ; Number of entries cached
kCacheHeaderSize equ 12 ; Offset to cached information
; Cache entry offsets
kMapHandleEntry equ 0 ; Handle to resource map this resource came from
kDataOffsetEntry equ 4 ; Offset to resource data from beginning of resource map
kResourceIDEntry equ 6 ; ID of this resource
kCacheEntrySize equ kResourceIDEntry + 2 ; Size of each cache entry
;_______________________________________________________________________________
; stack frame record definition added <sm1>stb
ResourceMgrStack RECORD {a6Link},decr
a6Link DS.L 1
ioBlock DS.B ioHQElSize
realCurMap ds.w 1
overrideCurMap ds.w 1
OverrideSysMapHndl ds.l 1
OverrideSysMap ds.l 1
doOverrides ds.w 1
localSize EQU *
ENDR
; Length of length longword
lenWdLen EQU 4 ; a longword is 4 bytes.
; Special number for resource overrides <SM7> rb
kROMMapRefNum EQU 1 ; 1 has always been the ROM <SM7> rb
kFakeResourceOverrideMapRefNum equ 3 ; 3 is not a valid reference number, so itÕs safe to use <SM7> rb
;_______________________________________________________________________________
;
; Equates added after <01jan85> by BBM
;_______________________________________________________________________________
ROMRsrcStart EQU $1A ; offset to beggining of rom Rsrc stuff <28aug85> BBM
preKey EQU $20B7A185 ; first key in preload key info <20jun85> BBM
preDataBuff EQU $00 ; offset key info inside cache 00:
preVersion EQU preDataBuff+4 ; four byte version number 04:
preLock EQU preVersion+4 ; Ptr to end of preload locked rsrcs 08:
preUnLock EQU preLock+4 ; Ptr to end of preload unlocked rsrcs 0C:
preExtra EQU preUnLock+4 ; Ptr to end of extra preload rsrcs 10:
preEnd EQU preExtra+4 ; $0C bytes reserved for future use 14:
preSize EQU preEnd-preDataBuff ; size of preload stuff in rsrc fork <11jul85> BBM
HSCache EQU RMGRHiVars ; start lowmem cache for HandleScan 00: <12mar85> BBM
HSCRType EQU HSCache ; D3.L = resource type cache 00:
HSCHandle EQU HSCRType+4 ; A1.L = handle to resource 04:
HSCROffset EQU HSCHandle+4 ; A2.L = offset to resource entry 08:
HSCTOffset EQU HSCROffset+4 ; A3.L = offset to TypeCount 0C:
HSCMapHndl EQU HSCTOffset+4 ; A4.L = handle to map 10:
HSCEntryCnt EQU HSCMapHndl+4 ; D4.W = entry count (-1) 14:
HSCTypeCnt EQU HSCEntryCnt+2 ; D5.W = type count (-1) 16:
HSCMapRNum EQU HSCTypeCnt+2 ; D6.W = Rsrc File Reference number 18:
ResOneDeep EQU HSCMapRNum+2 ; flag for onedeep (auto-cleared) 1A: <12mar85> BBM
GIROneDeep EQU ResOneDeep+1 ; flag (true means insert rom map) 1B: <09jul85> BBM
GIRIndex EQU GIROneDeep+1 ; last index + 1 used by GetIndResource 1C: <09jul85> BBM
NewResDefEnd EQU HSCache+$20 ; end of low mem space 20: <17jun85> BBM
ENDIF ; ...already included