TweetFollow Us on Twitter

Volume Number:1
Issue Number:7
Column Tag:Assembly required

Using the Common Resources

By Frank Alviani

Resources are the most mystifying of all the Mac technology, mainly because they are undocumented, and not usually found on other computers. The purpose of resources are to seperate text, icons, fonts, menu items and dialogs from the executable source code of a program where they can be easily changed without re-compilation. With the resource editor and other tools, this opens up a world of “user customized” programs. The user literally changes the program resources to his own tastes. This makes for an exciting possibility in software adaptation that has yet to be fully explored. In the meantime, programmers still must struggle to make use of resources effectively.

A big problem is not having adequate documentation of the format of each resource in terms of a binary file specification; exactly how many bytes and in what format each resource item is specified. While the RMaker provides an easy way to assembly resources, it does little to explain their internal format. The Apple Assembler has the ability to compile resources directly, offering an alternative to the RMaker utility. All that is lacking is the correct assembler source code format of each resource. Now Frank Alviani has filled this omission gap by providing us with the assembler format of all the major resources. This information should go a long way toward improving the resource void. We encourage others to help in this area by sending in articles or information on resources to help improve our understanding of this vital Mac concept. [David E. Smith, Editor]

Linker or RMaker

The big advantage to using the linker rather than the RMaker is flexability. You can control every detail - type style, etc. To balance this, linking is significantly longer and certain RMaker capabilities simply don’t exist - “linking” in picture resources, for example. With RMover, those disadvantages are pretty small, however.

Only the reasonably common resources are documented here (mostly those in volume 1 of IM). I didn’t include the Font resource defs, since nobody in their right minds would do a font in assembler (I had to do 2 in assembler for a DEC Pro system when I wrote a custom screen manager and I KNOW how bad that is!!). While there are probably others that aren’t included, I’ve had no use for them.

The few notes regard (1) The correction to the “control type” field in the Control resource, and (2) an explanation of the enabling mask field in the Menu resource. These are naturally confusing since IM is wrong or silent on the matters.

I decided to take this approach to building a “prototypes” file, rather than use macros, because (a) A typical macro call would be too big to fit on a line, and I am somewhat fussy about the appearance of my code (I have enough trouble without messy code confusing me further...) (b) I include explanatory comments on each line, so I don’t have to keep referring to reference material for each field. Disk space is virtually free, so why not?

;Resource Prototypes for Assembler usage
;Frank Alviani
;More verbose than macros, but easier to copy & fill in...
;ALL resources using local labels (labels starting with @) must
;be bracketed by regular labels; local labels can be re-used only
;if the duplicates are separated by regular labels. This applies
;even if no warning appears in the resource prototype!
;These are arranged roughly alphabetically, altho the DLOG/ALRT/DITL
;are grouped together at the end.
;In general # represents a numeric field normally filled in.
;The name and attribute fields on the RESOURCE line are optional.
;The idea is to have this in one editor window, and to copy to the
;resource file being built as needed. This will hopefully speed the
;process, and give flexability the RMaker doesn’t.
;There are some additional explanatory comments with various resources.
;Some of this is copied from MacTutor 1/4.






DOCBOX  EQU 0    ;standard document window
ALERT   EQU 1    ;alert
PLAIN   EQU 2    ;plain
PLAINSHDEQU 3    ;plain with shadow
NOGROWDOC EQU    4 ;document window w/o grow box
ROUNDBOXEQU 16   ;rounded-corner window (see IM for setting corner radius..)

CBUTTON EQU 0    ;simple button
CCHKBOX EQU 1    ;check box
CRADIO  EQU 2    ;radio button
USEWFNT EQU 8    ;add to above to use window’s fonts
CSCROLL EQU 16   ;scroll bar

; IDENTIFICATION resource - needed for Finder to locate Icon
 DC.B   AA1-@1
@1:DC.B ‘Ver. 0.1 3/31/85’

;BUNDLE resource
 RESOURCE ‘BNDL’ ### ‘name’ [(attr)]
 DC.L   ‘WCA1’   ;signature
 DC.W   0,1 ;data (doesn’t change)
 DC.L   ‘ICN#’   ;icon mappings
 DC.W   0 ;number of mappings - 1
 DC.W   0,128    ;map 0 to icon 128
 DC.L   ‘FREF’   ;FREF mappings
 DC.W   0 ;number of mappings - 1
 DC.W   0,128    ;map 0 to fref 128

;CONTROL resource
;NOTE - although the assembler definition of this claims that the
;“control type” field is a long word, IT LIES. Control type is a 16-bit

 RESOURCE ‘CNTL’ ### ‘name’ [(attr)]
 DC.W   # ;top
 DC.W   # ;left
 DC.W   # ;bottom
 DC.W   # ;right
 DC.W   # ;initial value
 DC.W   0 ;visible (T/F)
 DC.W   # ;max value
 DC.W   # ;min value
 DC.W   # ;control type
 DC.L   0 ;refCon
 DC.B   @2-@1    ;title length (at least 1)
@1:DC.B ‘xxx’    ;title

;CURSOR resource
 RESOURCE ‘CURS’ ### ‘name’ [(attr)]
 DC.L   #,# ;1st 8 bytes of cursor
 DC.L   #,# ;2nd 8 bytes
 DC.L   #,# ;3rd 8 bytes
 DC.L   #,# ;4th 8 bytes
 DC.L   #,# ;1st 8 bytes of mask
 DC.L   #,# ;2nd 8 bytes
 DC.L   #,# ;3rd 8 bytes
 DC.L   #,# ;4th 8 bytes  
 DC.W   #,# ;h,v of hot spot
;FREF resource
 RESOURCE ‘FREF’ ### ‘name’ [(attr)]
 DC.B   ‘APPL’,0,0,0
;ICN# resource
 RESOURCE ‘ICN#’ ### ‘name’ [(attr)]
;there’d usually be an ‘include’ here...

;MENU resource
;NOTE - the “enable field”: bits are number right to left 0-15. Bit
;1 is the first menu item. A “0” bit in the mask disables that item.
;I haven’t tried it, but I think turning off bit 0 of the mask
;disables the entire menu..

 RESOURCE ‘MENU’ ### ‘name’ [(attr)]
lbl:  DC.W1 ;MENU ID
 DC.W   0 ;width holder
 DC.W   0 ;height holder
 DC.L   0 ;std menu pro holder
 DC.L   $1FF;enable all items
 DC.B   @2-@1    ;title length (in bytes)
@1:DC.B 20;title (this is the apple)

;MENU ITEM resource
 DC.B   # ;item length
 DC.B   ‘xxx’    ;menu item
 DC.B   0 ;no icon
 DC.B   0 ;keyboard equivalent
 DC.B   0 ;marking character
 DC.B   0 ;style of item’s text
;PATTERN stuff
 RESOURCE ‘PAT ‘ ### ‘name’ [(attr)]
 DC.L   #,# ;1st, 2nd 4 bytes of pattern
 RESOURCE ‘PAT#’ ### ‘name’ [(attr)]
 DC.W   # ;# of patterns
 DC.L   #,# ;1st, 2nd 4 bytes of pattern #1

;STRING resource
 RESOURCE ‘STR ‘ ### ‘name’ [(attr)]
 DC.B   @2-@1    ;text length
@1:DC.B ‘xxx’    ;text

;STRING LIST resource
 RESOURCE ‘STR#’ ### ‘name’ [(attr)]
 DC.W   # ;count of strings
 DC.B   @2-@1    ;text length - string #1
@1:DC.B ‘xxx’    ;text

;WINDOW resource
 RESOURCE ‘WIND’ ### ‘name’ [(attr)]
 DC.W   # ;top
 DC.W   # ;left
 DC.W   # ;bottom
 DC.W   # ;right
 DC.W   # ;window type
 DC.W   # ;visible (T/F)
 DC.W   # ;draw goAway (T/F)
 DC.L   0 ;refCon (available)
 DC.B   @2-@1    ;title length
@1:DC.B ‘xxx’    ;title

; -- Dialog / Alert / DITL are grouped together --

;DIALOG resource
 RESOURCE ‘DLOG’ ### ‘name’ [(attr)]
 DC.W   # ;top
 DC.W   # ;left
 DC.W   # ;bottom
 DC.W   # ;right
 DC.W   # ;window type
 DC.B   # ;visible (T/F)
 DC.B   # ;goAway flag (T=has close box)
 DC.L   0 ;refCon
 DC.W   # ;ID of DITL list
 DC.B   @2-@1    ;text length
@1:DC.B ‘xxx’    ;text

;ALERT resource
 RESOURCE ‘ALRT’ ### ‘name’ [(attr)]
 DC.W   # ;top
 DC.W   # ;left
 DC.W   # ;bottom
 DC.W   # ;right
 DC.W   # ;resource ID of DITL list
 DC.W   # ;stages (see IM for details..)

;DITL resource
 RESOURCE ‘DITL’ ### ‘name’ [(attr)]
 DC.W   # ;# of items - 1

lbl:  DC.L0 ;handle holder
 DC.W   # ;top
 DC.W   # ;left
 DC.W   # ;bottom
 DC.W   # ;right
 DC.B   type;item-type
 DC.B   @2-@1    ;item length (MUST BE EVEN)
@1:DC.B ‘xxx’    ;item

; items must be even length
; item types are as follows
;  control item - control-item + 4
;     button0
;check box1
;radio button  2
;resource 3
;static text8
;edit text16
;icon item32
;quickdraw pict  64
;user item0
; disable item - item + 128
; system icons
;stop   0
;note   1
;alert  2


Community Search:
MacTech Search:

Software Updates via MacUpdate

Cocktail 8.1.2 - General maintenance and...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
Cyberduck 4.6.4 - FTP and SFTP browser....
Cyberduck is a robust FTP/FTP-TLS/SFTP browser for the Mac whose lack of visual clutter and cleverly intuitive features make it easy to use. Support for external editors and system technologies such... Read more
Herald 5.0.2 - Notification plugin for M...
Note: Versions 2.1.3 (for OS X 10.7), 3.0.6 (for OS X 10.8), and 4.0.8 (for OS X 10.9) are no longer supported by the developer. Herald is a notification plugin for, Apple's Mac OS X email... Read more
DEVONthink Pro 2.8.3 - Knowledge base, i...
Save 10% with our exclusive coupon code: MACUPDATE10 DEVONthink Pro is your essential assistant for today's world, where almost everything is digital. From shopping receipts to important research... Read more
Boom 2 1.0.1 - System-wide pro audio app...
Boom 2 is a system-wide volume booster and equalizer app that is designed especially for OS X 10.10 Yosemite. It comes with a smart interface, self-calibrates itself according to your Mac, offers... Read more
Apple Security Update 2015-001 - For OS...
Apple Security Update 2015-001 is recommended for all users and improves the security of OS X. For detailed information about the security content of this update, please visit: Read more
Drive Genius 4.0.1 - Powerful system uti...
Drive Genius 4 gives you faster performance from your Mac while also protecting it. The award-winning and improved DrivePulse feature alerts you to hard drive issues before they become major problems... Read more
Yosemite Cache Cleaner 9.0.3 - Clear cac...
Yosemite Cache Cleaner is an award-winning general purpose tool for OS X. YCC makes system maintenance simple with an easy point-and-click interface to many OS X functions. Novice and expert users... Read more
xScope 4.1.1 - Onscreen graphic measurem...
xScope is powerful set of tools that are ideal for measuring, inspecting, and testing on-screen graphics and layouts. Its tools float above your desktop windows and can be accessed via a toolbar,... Read more
OS X Yosemite 10.10.2 - Apple's lat...
OS X Yosemite is Apple's newest operating system for Mac. An elegant design that feels entirely fresh, yet inherently familiar. The apps you use every day, enhanced with new features. And a... Read more

Unlock Sunshine Girl in Ironkill with th...
Unlock Sunshine Girl in Ironkill with this special 148Apps code Posted by Rob Rich on January 29th, 2015 [ permalink ] Robo-fighter Ironkill has been out on iOS a | Read more »
Crossroad Zombies Review
Crossroad Zombies Review By Jordan Minor on January 29th, 2015 Our Rating: :: CROSSWALKING DEADiPad Only App - Designed for the iPad Crossroad Zombies is a rough draft of a cool genre mash-up.   | Read more »
Blood Brothers 2 – Tips, Cheats, and Str...
War is hell: Is it the kind of hell you want to check out? Read our Blood Brothers 2 review to find out! Blood Brothers 2, DeNA’s follow-up to the original Blood Brothers, is an intriguing card collecting / role-playing / strategy hybrid. There’s... | Read more »
Blood Brothers 2 Review
Blood Brothers 2 Review By Nadia Oxford on January 29th, 2015 Our Rating: :: AN AGGRAVATING RELATIVEUniversal App - Designed for iPhone and iPad Blood Brothers 2 is built on a simple, solid foundation, but its free-to-play system... | Read more »
I AM BREAD, the Toast of the Town, is Ro...
Have you ever dreamt of being deliciously gluten-y? Do you feel passionate about Rye and Wheat? The guys at Bossa Studios do and that is why they are bringing I AM BREAD to iOS soon. The loafy app will feature all the new content that is being... | Read more »
Fahrenheit: Indigo Prophecy Remastered R...
Fahrenheit: Indigo Prophecy Remastered Review By Jennifer Allen on January 29th, 2015 Our Rating: Universal App - Designed for iPhone and iPad 10 years after its initial release and Fahrenheit: Indigo Prophecy still feels like a... | Read more »
Evolve: Hunters Quest is a Match-3 That...
Evolve: Hunters Quest is a Match-3 That Has You Hunting Up Some Big Game. Posted by Jessica Fisher on January 29th, 2015 [ permalink ] | Read more »
Destructamundo Review
Destructamundo Review By Jordan Minor on January 29th, 2015 Our Rating: :: WRECKING CREWUniversal App - Designed for iPhone and iPad Destructamundo blows up real good.   | Read more »
The Sandbox Gets Exclusive Update, Adds...
The Sandbox Gets Exclusive Update, Adds Invincible Characters Campagin Posted by Tre Lawrence on January 29th, 2015 [ permalink ] | Read more »
Mean Girls: The Game Review
Mean Girls: The Game Review By Jordan Minor on January 29th, 2015 Our Rating: :: FETCHUniversal App - Designed for iPhone and iPad A Mean Girls tower defense game makes way more sense than you’d think.   | Read more »

Price Scanner via

Back in stock: Refurbished iPod nanos for $99...
The Apple Store has Apple Certified Refurbished 16GB iPod nanos available for $99 including free shipping and Apple’s standard one-year warranty. That’s $50 off the cost of new nanos. Most colors are... Read more
New Good Management Suite Simplifies Enterpri...
Good Technology has announced the availability of the Good Management Suite, a comprehensive cross-platform solution for organizations getting started with mobile business initiatives. Built on the... Read more
15-inch 2.0GHz Retina MacBook Pro (refurbishe...
The Apple Store has Apple Certified Refurbished previous-generation 15″ 2.0GHz Retina MacBook Pros available for $1489 including free shipping plus Apple’s standard one-year warranty. Their price is... Read more
15-inch 2.5GHz Retina MacBook Pro on sale for...
Amazon has the 15″ 2.5GHz Retina MacBook Pro on sale for $2319.99 including free shipping. Their price is $180 off MSRP, and it’s the lowest price available for this model from any reseller. Read more
iPad Turns Five – The ”Book Mystique
Five years ago this week, the late Steve Jobs took the stage at an Apple special press event to unveil the first Apple iPad — a slab-shaped, hand-holdable device that was to shake the personal... Read more
Sale! 15-inch Retina MacBook Pros for up to $...
B&H Photo has the new 2014 15″ Retina MacBook Pros on sale for $150 off MSRP for a limited time. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.2GHz Retina MacBook Pro: $1889.99... Read more
Apple refurbished Mac minis for up to $150 of...
The Apple Store has restocked Apple Certified Refurbished 2014 Mac minis, with models available starting at $419. Apple’s one-year warranty is included with each mini, and shipping is free: - 1.4GHz... Read more
Apple Releases New Tranche Of OS Updates For...
Apple has released incremental bugfix and security updates for its most recent Mac and iOS versions. OS X Yosemite 10.10.2 Update Apple says this update includes the following improvements: Resolves... Read more
Samsung To Be Main Supplier Of A9 Chips For i...
Korea’s Maeil Business Newspaper reports that Samsung has beat out its chipmaking rivals, Taiwan’s Qualcomm and TSMC, as supplier of chipsets for the next generations of both its own Galaxy S6 and... Read more
Save up to $340 on iMacs with Apple Certified...
The Apple Store has Apple Certified Refurbished iMacs available for up to $340 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free. These are the best prices on... Read more

Jobs Board

*Apple* Systems Engineer - Pre Sales, Educat...
…is responsible for proactively providing technical expertise to drive sales of Apple solutions into assigned accounts. The SE architects, validates, and assists in Read more
*Apple* Solutions Consultant - Retail Sales...
As an ambassador of the Apple brand, the ASC is accountable for driving sales performance by: Connecting with customers. Discovering customers' needs and values. Showing Read more
*Apple* Solutions Consultant - Retail Sales...
As an ambassador of the Apple brand, the ASC is accountable for driving sales performance by: Connecting with customers. Discovering customers' needs and values. Showing Read more
*Apple* Tree Children's Center is hirin...
Apple Tree Learning Center is Hiring Preschool Teachers! Phoenix Childrens Academy is a national leader in the early childhood education industry and we are currently Read more
*Apple* Solutions Consultant - Retail Sales...
**Job Summary** As an Apple Solutions Consultant (ASC) you are the link between our customers and our products. Your role is to drive the Apple business in a retail Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.