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

Trend Micro 11.0.2062 - An essential sec...
Trend Micro Antivirus provides essential security for macOS with real-time malware detection and mitigation in an affordable solution with a simple, intuitive interface. However, be aware that more... Read more
Backblaze - Online backup serv...
Backblaze is an online backup service designed from the ground-up for the Mac. With unlimited storage available for $6 per month, as well as a free 15-day trial, peace of mind is within reach with... Read more
Pro Video Formats 2.2.1 - Updates for pr...
Pro Video Formats includes support for the following professional video codecs: Apple Intermediate Codec Apple ProRes AVC-Intra 50 / 100 / 200 / 4:4:4 / LT AVC-LongG XAVC XF-AVC DVCPRO HD HDV XDCAM... Read more
Boom 3D 1.3.11 - $19.99
Boom 3D is a revolutionary app with 3D Surround Sound and phenomenally rich and intense audio that is realistic and works on any headphones. Features 3D surround sound Built-in audio player... Read more
Final Cut Pro 10.5.2 - Professional vide...
Redesigned from the ground up, Final Cut Pro combines revolutionary video editing with a powerful media organization and incredible performance to let you create at the speed of thought.... Read more
Chromium 89.0.4389.72 - 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 89.0.4389.72: Complete list of changes can... Read more
iMovie 10.2.3 - Edit personal videos and...
With a streamlined design and intuitive editing features, iMovie lets you create Hollywood-style trailers and beautiful movies like never before. Browse your video library, share favorite moments,... Read more
OmniPlan 4.2.5 - Professional-grade proj...
With OmniPlan, you can create logical, manageable project plans with Gantt charts, schedules, summaries, milestones, and critical paths. Break down the tasks needed to make your project a success,... Read more
Compressor 4.5.2 - Adds power and flexib...
Compressor adds power and flexibility to Final Cut Pro X export. Customize output settings, work faster with distributed encoding, and tap into a comprehensive set of delivery features. Features:... Read more
Motion 5.5.1 - Create and customize Fina...
Motion is designed for video editors, Motion 5 lets you customize Final Cut Pro titles, transitions, and effects. Or create your own dazzling animations in 2D or 3D space, with real-time feedback as... Read more

Latest Forum Discussions

See All

Frogger in Toy Town's latest update...
Konami Digital Entertainment has announced today that their Apple Arcade title Frogger in Toy Town has been updated to introduce a new ranked Endurance Mode. This new game variant's arrival is also accompanied by a few other changes. [Read more] | Read more »
Mitoza is surreal adventure toy you can...
The folks behind the Rusty Lake games have just put a new title onto the App Store. Second Maze, Rusty Lake's collaborative publishing brand, has just brought this 10 year old adventure game from Gal Mamalya to mobile. The best part about all of... | Read more »
Pocket Gamer Awards 2021: You have five...
Three weeks ago our sister site, Pocket Gamer, entered the voting stage for the upcoming Pocket Gamer Awards 2021 and is now in the final stretch. You only have a few hours left to vote for the games you’ve enjoyed on mobile in the past year, as... | Read more »
Patty Stack is a casual arcade game, ava...
Patty Stack is a casual arcade title that's available now for iOS and Android. It's the debut game from developer Feeka Games tasks players with making an increasingly giant burger tower. Think of it as Tower Bloxx but more edible. [Read more] | Read more »
Distract Yourself With These Great Mobil...
There’s a lot going on right now, and I don’t really feel like trying to write some kind of pithy intro for it. All I’ll say is lots of people have been coming together and helping each other in small ways, and I’m choosing to focus on that as I... | Read more »
Genshin Impact Guide - Gacha Strategy: W...
This is part 2 of our Genshin Impact gacha strategy guides. See part 1 here. You can check out more guides for Genshin Impact here. | Read more »
Slashy Camp is a new endless runner insp...
Blue Wizard Digital has released Slashy Camp onto iOS and Android after it spent a short amount of time in early access. [Read more] | Read more »
Kinder World is a relaxing game about lo...
Lumi Interactive is releasing a game called Kinder World later this year on iOS and Android, which is all about looking after houseplants. [Read more] | Read more »
Steam Link Spotlight - Fights in Tight S...
Steam Link Spotlight is a feature where we look at PC games that play exceptionally well using the Steam Link app. Our last entry was on Hades. Read about how it plays using Steam Link over here. | Read more »
Lyxo, the light-based puzzler for mobile...
Vienna-based independent game studio Emoak has just released its unique light-based puzzler for iOS and Android. Founded in 2014 by Tobias Sturn, the company is also the creative force behind the infinite climbing game Paper Climb, as well as the... | Read more »

Price Scanner via

Weekend Sale: $100 off Apple iPad Magic Keybo...
Amazon has Apple iPad Magic Keyboards on sale for $100 off MSRP for a limited time. Amazon’s prices are the lowest available for iPad Magic Keyboard from any Apple reseller this weekend: – Magic... Read more
Gazelle now offering a full line of refurbish...
Gazelle is now offering a full range of discounted, refurbished, unlocked Apple iPhone 12 models starting at $649. iPhones are offered in Fair, Good, and Excellent conditions, and multiple colors are... Read more
These are the latest discounted iPhones Apple...
Apple has a range of Certified Refurbished iPhones available right now starting at only $339. Apple includes a standard one-year warranty, new outer shell, and shipping is free. According to Apple, “... Read more
Save up to $64 on new M1 MacBook Airs at Expe...
Apple reseller Expercom has 2020 13″ M1 MacBook Airs on sale for $51-$64 off Apple’s MSRP with prices starting at $947.96. In addition to their MacBook Air sale prices, take $50 off AppleCare+ when... Read more
Discounts available on 16″ MacBook Pros with...
Upgrade a 16″ 6-Core or 8-Core MacBook Pro from 16GB of standard RAM to 32GB at Adorama, and save $100-$210 over Apple’s price for this custom option: – 16″ 6-Core MacBook Pro/32GB RAM: $2699, save $... Read more
10.9″ iPad Airs on sale for $50-$70 off Apple...
Amazon has new 2020 10.9″ Apple WiFi iPad Airs in stock and on sale today for up to $70 off MSRP with prices starting at $549. Note that Amazon’s sale price might be restricted to certain colors (see... Read more
Apple restocks 2020 27″ 5K iMacs for up to $3...
After an initial offering in January, Apple has restocked a full line of Certified Refurbished 2020 27″ 5K iMacs starting at $1529 and up to $350 off original MSRP. Apple’s one-year warranty is... Read more
Sale! 16″ 8-Core MacBook Pro for $2449, $350...
Apple reseller Adorama has the 16″ 2.3GHz 8-Core Space Gray MacBook Pro in stock and on sale today for $2449 including free shipping. Their price is $350 off Apple’s MSRP for this model, and it’s the... Read more
Roundup of 13″ Multi-Core Intel MacBook Pro s...
Apple resellers are offering significant sales & deals this week on 2020 13″ MacBook Pros with 10th generation Intel CPUs. Take up to $250 off Apple’s MSRP, get free fast shipping, and/or pay no... Read more
64GB iPhone 8 Plus available for $379 at Appl...
Apple has the 64GB iPhone 8 Plus in Space Gray & Gold colors available for $379 today, Certified Refurbished. Each phone is unlocked and comes with Apple’s standard 1-year warranty and free... Read more

Jobs Board

Geek Squad Advanced Repair *Apple* Professi...
**795178BR** **Job Title:** Geek Squad Advanced Repair Apple Professional **Job Category:** Store Associates **Store Number or Department:** 001406-Allen Park-Store Read more
Geek Squad *Apple* Consultation Professiona...
**796549BR** **Job Title:** Geek Squad Apple Consultation Professional **Job Category:** Store Associates **Store Number or Department:** 001800-Hot Springs-Store Read more
*Apple* Mobility Specialist - Best Buy (Unit...
**796014BR** **Job Title:** Apple Mobility Specialist **Job Category:** Store Associates **Store Number or Department:** 001776-Woodmore Towne Centre-Store **Job Read more
Systems Architect, *Apple* Production Engin...
…package beginning on your first day? If so, we hope you'll keep reading! The Apple Sales Engineering and account team is looking for a stellar presales engineer with Read more
Systems Engineer, Webscale, *Apple* Retail,...
…beginning on your first day? If so, we hope you'll keep reading! The Apple Sales Engineering team is looking for a pre-sales engineer with Enterprise engineering Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.