bartop

palmoswerks ARCHIVE
Palm OS programming tips from a (former) CodeWarrior insider

header

Navigation

Search
Home
About
Stories
Stuff I Like
Articles
PilRC
CodeWarrior
palmos.techwood.org
DevTools List
Palm OS Dev FAQ

Converting from Mac OS resources to PilRC with V9

I orginally wrote this last year while working on V9, and its been stuck on my hard drive since then. By the way, I'm sorry I've not been posting much over the last month. Work on V9.2 has been heavy, and I've also been preparing for the 2003 "SXSW" conference here in Austin. I did the schedule application again this year, rewriting a lot of the code from the 2002 app. In the process, I made it much, much faster, and I added a few new capabilities. I also tried implementing a few features that didn't get completed and debugged in time for the show. I'll talk about this more in the near future

Converting a CodeWarrior for Palm OS Project from the Mac OS 68K Linker to the Palm OS 68K Linker

The conversion process is fairly easy, depending on how you want to setup your resources. In this document, we will assume that you will want to convert all resources to PilRC format and use that for your new targets.

Note: while you can convert static library projects to the new linker, static libraries are compatible betweenthe two linkers, so conversion may not be necessary.

Step 1: Open your Old Project

First, make sure your project can be opened and will build in CW for Palm OS V9 using the old Mac OS 68K Linker. Having a working project from which to start will make the whole process easier.

Step 2: Clone a target in your project

It is easier to do the conversion using a clone of your existing target. To clone a target, go to the target tab of the project file window, then choose Project/Create Target. Choose the "clone existing target" option, pick one of your targets, and give the new target a similar name.

Step 3: Open target settings panels

Double click on both the new target and the one you cloned it from to bring up the Target Settings dialog for each one.

Step 4: Fix linkers and file associations

In the new target's Target Settings panel, change the Linker to "Palm OS 68K", and the post-linker to "None".

In the File Mappings panel, hit "Factory Settings" to make sure all file associations are correct.

Step 5: Setup the new linker

Go to the Palm OS 68K Target panel in the new target and the 68K Target panel for the old target. Set the target type in the new panel to match the settings in the old one.

The standard/expanded mode choice is now part of the target type setting, rather than independent. If you were building a code resource before, you may want to use the new "68K Shared Library" setting instead.

If you were building a static library, copy the library name from the old panel to the new one, and you're done. Repeat steps 2-5 for the other targets in your project, and delete the old targets after you're done.

Step 6: Migrating PalmRez Settings

In the old target, change to the PalmRez Post Linker panel. Copy the output file from this panel into the file name field of the new target's settings.

Now, switch the new target to the PRC File Settings panel. You should copy the type and creator ID from the PalmRez panel into the type and creator fields of the new panel. Do the same thing for the various header flags checkboxes and the database name field. The version field in the old panel corresponds to the DB Version field in the new panel.

If you had a value in the HackMaster Hacks section of the PalmRez panel, you will need to add a HACK entry to your new target's PilRC-format "RCP" file.

Step 7a: Converting Resources using RSRC2RCP

To convert your resources to RCP format for use with the PilRC compiler, you can use the helpful RSRC2RCP program, available at

http://www.palmgear.com/software/showsoftware.cfm?prodID=42412

This application takes your a .rsrc file and a header file as inputs, and outputs a .rcp file and a collection of Windows Bitmap (.bmp) files.

The usage of this tool is explained in the documentation that accompanies it. One quirk: the tool wants as input the actual binary .rsrc file that's normally in your RESOURCE.FRK folder, not the zero-byte "data fork" file that lives outside this folder.

As reference, I used this command line to convert the resources for the Tic-Tac-Toe example included with CodeWarrior for Palm OS V9, after I had copied the resource fork of Tic-Tac-Toe.rsrc and the header file that Constructor had generated into my working directory.

rsrc2rcp -I TicTacToe_Res.h -rsrc Tic-Tac-Toe.rsrc -v -oRcp TicTacToe.rcp

Step 7b: Converting Resources using PRCExplorer

You can also convert resources using Palm Application Explorer, also known as PRCExplorer. A version of this application is included with V9 in the "CW for Palm OS Tools\PRCExplorer" folder, and updates can be downloaded from

http://www.palmgear.com/software/showsoftware.cfm?prodID=40542

Using Palm Application Explorer, you can open a PRC file output by the Mac OS 68K Linker and PalmRez and decompile all of its resources to RCP and BMP files. Just select your PRC file in the Palm Application Explorer window and choose "File/Save Source" from the menu. This technique may be easier for a project with a lot of .rsrc files, or a project that uses Rez scripts to describe many of the resources, but it has the disadvantage of not preserving the correspondence between the resources and the resource header file.

Step 8: Remove the old resources, add the new

Remove the old .rsrc resource files from your target by selecting all of them, and clicking on the target dot in the Project window. Then, use the "Add Files..." command to add the .rcp file to your project.

Step 9: Handling name and version resources

The Palm OS 68K Linker panel lets you specify your application name and version string directly in a IDE pref panel, rather than having them specified in resources. If you choose to use that feature, those entries should be checked and corrected in the new targets Palm OS 68K Linker panel. After doing that, search the RCP file for the "VERSION" and "APPLICATIONICONNAME" resources. Delete them from the RCP file to avoid getting a link error about duplicated resources when you build.

brought to you by weblogger.com


Send feedback to combee@techwood.org
Copyright © 2004 Benjamin L. Combee
Palm OS is a registered trademark of PalmSource, Inc.
Metrowerks and CodeWarrior are registered trademarks of Metrowerks Inc.

The views expressed on this website/weblog are those of mine alone and do not necessarily reflect the views of PalmSource or Metrowerks.

This is a Manila Site

qwertYAK / frobnovich