![]() Acrobat file (116K) |
![]() ClarisWorks 4 file (36K) |
![]() QuickView file (473K) |
T E C H N O T E :
A Technique for Figuring Out
a Resource's Base Value
TECHNOTE 1006 | OCTOBER 1995 |
By Matthew Xavier Mora
mxmora@apple.com
Apple Developer Technical Support (DTS)
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;and for those who still program in 68k asm, you can use this function:
begin
GetResBase := BOR($C000, BSL(longint(((-resID)-1)),5));
end;
;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
END
Return to Technotes Table of Contents
Return to About Macintosh Technotes
Return to Developer Services and Products
Send feedback to devfeedback@applelink.apple.com.