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

A Better Finder Rename 10.00b1 - File, p...
A Better Finder Rename is the most complete renaming solution available on the market today. That's why, since 1996, tens of thousands of hobbyists, professionals and businesses depend on A Better... Read more
CrossOver 14.1.6 - Run Windows apps on y...
CrossOver can get your Windows productivity applications and PC games up and running on your Mac quickly and easily. CrossOver runs the Windows software that you need on Mac at home, in the office,... Read more
Printopia 2.1.14 - Share Mac printers wi...
Run Printopia on your Mac to share its printers to any capable iPhone, iPad or iPod Touch. Printopia will also add virtual printers, allowing you to save print-outs to your Mac and send to apps.... Read more
Google Drive 1.24 - File backup and shar...
Google Drive is a place where you can create, share, collaborate, and keep all of your stuff. Whether you're working with a friend on a joint research project, planning a wedding with your fiancé, or... Read more
Chromium 45.0.2454.85 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. Version 45.0.2454.85: Note: Does not contain the "... Read more
OmniFocus 2.2.5 - GTD task manager with...
OmniFocus helps you manage your tasks the way that you want, freeing you to focus your attention on the things that matter to you most. Capturing tasks and ideas is always a keyboard shortcut away in... Read more
iFFmpeg 5.7.1 - Convert multimedia files...
iFFmpeg is a graphical front-end for FFmpeg, a command-line tool used to convert multimedia files between formats. The command line instructions can be very hard to master/understand, so iFFmpeg does... Read more
VOX 2.6 - Music player that supports man...
VOX is a beautiful music player that supports many filetypes. The beauty is in its simplicity, yet behind the minimal exterior lies a powerful music player with a ton of features and support for all... Read more
Box Sync 4.0.6567 - Online synchronizati...
Box Sync gives you a hard-drive in the Cloud for online storage. Note: You must first sign up to use Box. What if the files you need are on your laptop -- but you're on the road with your iPhone? No... Read more
Carbon Copy Cloner 4.1.4 - Easy-to-use b...
Carbon Copy Cloner backups are better than ordinary backups. Suppose the unthinkable happens while you're under deadline to finish a project: your Mac is unresponsive and all you hear is an ominous,... Read more

You Can Play Madfinger Games' Unkil...
Madfinger Games - probably best known for the Dead Trigger series - has officially launched their newest zombie shooter (that isn't called Dead Trigger), named Unkilled. [Read more] | Read more »
KORG iELECTRIBE for iPhone (Music)
KORG iELECTRIBE for iPhone 1.0.1 Device: iOS iPhone Category: Music Price: $9.99, Version: 1.0.1 (iTunes) Description: ** 50% OFF Special Launch Sale - For a Limited Time **The ELECTRIBE reborn in an even smaller form A full-fledged... | Read more »
I am Bread (Games)
I am Bread 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: ‘I am Bread’ is the latest quirky adventure from the creators of 'Surgeon Simulator', Bossa Studios. This isn't the best thing... | Read more »
Rock(s) Rider - HD Edition (Games)
Rock(s) Rider - HD Edition 1.0.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.0 (iTunes) Description: *** PLEASE NOTE: Compatible with iPhone 4s, iPad 2, iPad mini, iPod touch (5th generation) or newer *** Do you... | Read more »
Rebuild 3: Gangs of Deadsville (Games)
Rebuild 3: Gangs of Deadsville 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: It's been a few years since the zombpocalypse turned the world's cities into graveyards and sent the few... | Read more »
Power Ping Pong (Games)
Power Ping Pong 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: Do you wield your bat with zen-like focus or do your balls of fury give you a killer spin? Table tennis goes mobile with a... | Read more »
Z.O.N.A Project X (Games)
Z.O.N.A Project X 1.00 Device: iOS Universal Category: Games Price: $1.99, Version: 1.00 (iTunes) Description: Z.O.N.A Project X - shooter in the post-apocalyptic world. | Read more »
Trick Shot (Games)
Trick Shot 1.0.6 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.6 (iTunes) Description: A game where all you have to do is throw a ball into a box, simple? Trick Shot is a minimalist physics puzzler with 90 levels... | Read more »
VoxelCity (Games)
VoxelCity 1.0.2 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.2 (iTunes) Description: Looking for a new city builder? Tired of social media anti-games with no strategy? Look no further! NO IAP EVER! VoxelCity is a... | Read more »
Goat Simulator MMO Simulator (Games)
Goat Simulator MMO Simulator 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: ** IMPORTANT - SUPPORTED DEVICESiPhone 4S, iPad 2, iPod Touch 5 or better.** Coffee Stain Studios brings next-gen... | Read more »

Price Scanner via

Near-Office Input Functionality Virtually Any...
Today Logitech introduced the Logitech K380 Multi-Device Bluetooth Keyboard and the Logitech M535 Bluetooth Mouse, giving users the freedom to work on any device, most anywhere. According to... Read more
College Student Deals: Additional $100 off Ma...
Take an additional $100 off all MacBooks and iMacs at Best Buy Online with their College Students Deals Savings, valid through September 4, 2015. Anyone with a valid .EDU email address can take... Read more
Will You Buy An iPad Pro? – The ‘Book Mystiqu...
It looks like we may not have to wait much longer to see what finally materializes as a new, larger-panel iPad (Pro/Plus?) Usually reliable Apple product prognosticator KGI Securities analyst Ming-... Read more
eFileCabinet Announces SMB Document Managemen...
Electronic document management (EDM) eFileCabinet, Inc., a hosted solutions provider for small to medium businesses, has announced that its SecureDrawer and eFileCabinet Online services will be... Read more
WaterField Designs Unveils American-Made, All...
San Francisco’s WaterField Designs today unveiled their all-leather Cozmo 2.0 — an elegant attach laptop bag with carefully-designed features to suit any business environment. The Cozmo 2.0 is... Read more
Apple’s 2015 Back to School promotion: Free B...
Purchase a new Mac or iPad at The Apple Store for Education and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free,... Read more
128GB MacBook Airs on sale for $100 off MSRP,...
B&H Photo has 11″ & 13″ MacBook Airs with 128GB SSDs on sale for $100 off MSRP. Shipping is free, and B&H charges NY sales tax only: - 11″ 1.6GHz/128GB MacBook Air: $799.99, $100 off MSRP... Read more
13-inch 2.5GHz MacBook Pro (refurbished) avai...
The Apple Store has Apple Certified Refurbished 13″ 2.5GHz MacBook Pros available for $829, or $270 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.... Read more
27-inch 3.2GHz iMac on sale for $1679, save $...
B&H Photo has the 27″ 3.2GHz iMac on sale for $1679.99 including free shipping plus NY sales tax only. Their price is $120 off MSRP. Read more
Apple and Cisco Partner to Deliver Fast-Lane...
Apple and Cisco have announced a partnership to create a “fast lane” for iOS business users by optimizing Cisco networks for iOS devices and apps. The alliance integrates iPhone with Cisco enterprise... Read more

Jobs Board

*Apple* Desktop Analyst - KDS Staffing (Unit...
…field and consistent professional recruiting achievement. Job Description: Title: Apple Desktop AnalystPosition Type: Full-time PermanentLocation: White Plains, NYHot Read more
Simply Mac *Apple* Specialist- Repair Techn...
Simply Mac is the greatest premier retailer of Apple products expertise in North America. We're looking for dedicated individuals to provide personalized service and Read more
Simply Mac *Apple* Specialist- Service Repa...
Simply Mac is the greatest premier retailer of Apple products expertise in North America. We're looking for dedicated individuals to provide personalized service and Read more
*Apple* Desktop Analyst - KDS Staffing (Unit...
…field and consistent professional recruiting achievement. Job Description: Title: Apple Desktop AnalystPosition Type: Full-time PermanentLocation: White Plains, NYHot Read more
Simply Mac- *Apple* Specialist- Store Manag...
Simply Mac is the largest premier retailer for Apple products and solutions. We're looking for dedicated individuals with a passion to simplify and enhance the Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.