ADC Home > Reference Library > Technical Notes > Legacy Documents > Tools >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

A Technique for Figuring Out a Resource's Base Value


In the chapter on the Resource Manager in Inside Macintosh: More Macintosh Toolbox, owned resources are explained, but the chapter does not include a sample of how to actually figure out the resource's base value. This Technote includes a shortcut in C, Pascal and ASM to accomplish this task.

This Technote is specifically aimed at those developers who need to know about a resource's ownership, such as developers working on Desk Accessories or Control Panels.

 [Oct 1 1995]

A Shortcut for Figuring Out a Resource's Base Value

The function GetResBase takes the driver number and returns the ID of the first resource owned by that driver. This is according to the private resource numbering convention documented in the Resource Manager chapter on page 1-48 of Inside Macintosh: More Macintosh Toolbox.

In C, you can use this macro:

#define GetResBase(id) (0xC000 | (((-(id)) - 1) << 5))

and in Pascal, you can use this function:

function GetResBase(resID: integer):integer;

    GetResBase := BOR($C000, BSL(longint(((-resID)-1)),5));

and for those who still program in 68k asm, you can use this function:

   ;FUNCTION GetResBase(driverNumber: INTEGER): INTEGER;

    GetResBase  FUNC

        MOVE.L  (SP)+,A0    ; Get return address
        MOVE.W  (SP)+,D0    ; Get driver number
        NOT.W   D0          ; Change to unit number
        ASL.W   #5,D0       ; Move it over in the word
        ORI.W   #$C000,D0   ; Add the magic bits
        MOVE.W  D0,(SP)     ; Return function result
        JMP (A0)            ; and return


Inside Macintosh: More Macintosh Toolbox, The Resource Manager, 1-48

Back to top

Change History


Originally written.


Revised to include Pascal and C versions of the shortcut.

Back to top


Acrobat gif

Acrobat version of this Note (52K)


Back to top

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.