bammi@cwruecmp.UUCP (Jwahar R. Bammi) (10/10/86)
Here is a real Gem of an utility, from CompuServe. It will let you compile resources created with RCS (any version) right into your program. No more hunting for the '.RSC' file. Please use it in your code. It will help others who like to run programs from different directories, it helps alleviate the dynamic memory allocation probelm somewhat as you don't need rsrc_load() anymore, and it will help people like me who can never seem to find the '.rsc' file when needed. enjoy, -- #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # rcsfix.c # This archive created: Fri Oct 10 16:22:30 1986 # By: Jwahar R. Bammi () export PATH; PATH=/bin:$PATH echo shar: extracting "'rcsfix.c'" '(7544 characters)' if test -f 'rcsfix.c' then echo shar: over-writing existing file "'rcsfix.c'" fi sed 's/^X//' << \SHAR_EOF > 'rcsfix.c' X/* RSCFIX.C 09/16/86 Ric Clayton */ X/* STCREATE.c 04/20/85 ATARI */ X/* RSCREATE.C 05/18/84 - 11/01/84 LKW */ X/* Fix something 12/10/84 - 12/10/84 Derek Mui */ X/* Fix the size 12/17/84 */ X/* For ST 04/20/85 Derek Mui */ X/* For code resident rsc 09/16/86 Ric Clayton */ X X/*****************************************************************************\ X* rcsfix.doc X* X* RSCFIX.C -- A resource fixer for code-resident resources. X* X* RSCFIX.C contains a set of routines to prepare a code-resident X* resource for use. It was derived from STCREATE.C, found in the X* RSCREATE folder on the Resource Disk supplied with the Atari X* Developer's Kit. X* X* The routines are driven by a main routine, rsc_fix(), which you X* call during your program initialization to prepare the resource. X* The routines perform 2 distinct functions on the resource. The X* first is to change all the offsets, generated by RSC, to address X* pointers. The second function is to change all the object X* rectangle coordinates and sizes from characters to pixels, X* according to the current screen resolution. X* X* First get the download the file RSCFIX.C and put it with your X* header files. (e.g. on the compiler disk with ALCYON, in the X* HEADERS folder with Megamax, in the INCLUDE folder with Micro-C X* Shell and Mark Williams C, etc.) X* X* Next, create the C source file using RCS or RCS2. To do this, X* run the RCS program, Open your resource file, select the Output X* option from the Global menu, select '.H' and '.C' ('.C' & '.RSH' X* for RCS2), click on OK, and Close your resource. Put the these X* files with your source file(s). X* X* Then, modify your source file to include the resource's C source X* and header files and 'RSCFIX.C'. Change your call to rsrc_load() X* to rsc_fix(). Change your call to rsrc_gaddr to load the tree X* pointer from the rs_trindex[] array. X* X* Limitations: The 'adj' macro takes care of objects that are not X* character aligned but seems to have trouble when the root object X* of a tree is NOT character aligned. Just make sure all your root X* objects are character aligned and you should not have any X* problems. X* X* The following code fragment illustrates the use of rsc_fix(). X* X* #include <obdefs.h> X* #include <gemdefs.h> X* . X* . X* . X* #ifndef BYTE / Take care of 'portability' / X* #define BYTE char / macros in the '.RSH' file. / X* #define WORD int X* #define LONG long X* #endif X* X* #include "resource.h" / The header file from RSC / X* #include "resource.rsh" / The C source file from RSC / X* X* OBJECT *tree; / Pointer to an object tree / X* . X* . X* / global declarations / X* . X* . X* #include <rscfix.c> / Code to fixup resource / X* X* void sort(v,n) X* char *v[]; X* int n; X* { X* . X* . X* } X* . X* . X* . X* void do_form( rsc_tree, exit_obj ) X* int rsc_tree; X* int exit_obj; X* { X* int xdial, ydial, wdial, hdial; X* int x, y, w, h; X* int object; X* X* tree = (OBJECT *) rs_trindex[ rsc_tree ]; X* X* form_center( tree, &xdial, &ydial, &wdial, &hdial ); X* x = xdial + wdial/2; X* y = ydial + hdial/2; X* w = gl_wbox; X* h = gl_hbox; X* form_dial( 0, x, y, w, h, xdial, ydial, wdial, hdial ); X* form_dial( 1, x, y, w, h, xdial, ydial, wdial, hdial ); X* X* objc_draw( tree, ROOT, MAX_DEPTH, xdial, ydial, wdial, hdial ); X* X* object = 0; X* X* while( object != exit_obj ) X* { X* object = form_do( tree, 0 ) & 0x7FFF; X* handle_object( tree, object ); X* . X* . X* . X* } X* X* form_dial( 2, x, y, w, h, xdial, ydial, wdial, hdial ); X* form_dial( 3, x, y, w, h, xdial, ydial, wdial, hdial ); X* } X* X* main() X* { X* if ( appl_init() >= 0 ) X* { X* rsc_fix(); X* . X* . X* graf_mouse( M_ON, 0x0L ); X* graf_mouse( ARROW, 0x0L ); X* do_form( TREE0, OKBUTTON ); X* . X* . X* appl_exit(); X* } X* } X* X\*****************************************************************************/ X X/* rcsfix.c */ X#include <obdefs.h> X#include <gemdefs.h> X X#ifndef BYTE /* Take care of 'portability' */ X#define BYTE char /* macros in the '.RSH' file. */ X#define WORD int /* i absolutely refuse to use */ X#define LONG long /* silly includes like portab.h */ X#define NIL (-1L) X#endif X X#include "resource.h" /* The header file from RSC */ X#include "resource.rsh" /* The C source file from RSC */ X X X#define adj(xywh, siz) (siz * (xywh & 0x00FF) + (xywh >> 8)) X X Xstatic void fix_trindex() X{ X int test, ii; X X for (ii = 0; ii < NUM_TREE; ii++) X { X test = (int) rs_trindex[ii]; X rs_trindex[ii] = (long) &rs_object[test]; X } X} X Xstatic void fix_str(where) Xlong *where; X{ X if (*where != NIL) X *where = (long) rs_strings[(int) *where]; X} X Xstatic void fix_objects() X{ X int test, ii; X int wchar, hchar; X X graf_handle( &wchar, &hchar, &ii, &ii ); X X for (ii = 0; ii < NUM_OBS; ii++) X { X rs_object[ii].ob_x = adj(rs_object[ii].ob_x, wchar); X rs_object[ii].ob_y = adj(rs_object[ii].ob_y, hchar); X rs_object[ii].ob_width = adj(rs_object[ii].ob_width, wchar); X rs_object[ii].ob_height = adj(rs_object[ii].ob_height, hchar); X test = (int) rs_object[ii].ob_spec; X X switch (rs_object[ii].ob_type) X { X case G_TITLE: X case G_STRING: X case G_BUTTON: X fix_str(&rs_object[ii].ob_spec); X break; X case G_TEXT: X case G_BOXTEXT: X case G_FTEXT: X case G_FBOXTEXT: X if (test != NIL) X rs_object[ii].ob_spec = X (char *) &rs_tedinfo[test]; X break; X case G_ICON: X if (test != NIL) X rs_object[ii].ob_spec = X (char *) &rs_iconblk[test]; X break; X case G_IMAGE: X if (test != NIL) X rs_object[ii].ob_spec = X (char *) &rs_bitblk[test]; X break; X X default: X break; X } /* switch */ X } /* for */ X} X Xstatic void fix_tedinfo() X{ Xint ii; X X for (ii = 0; ii < NUM_TI; ii++) X { X fix_str(&rs_tedinfo[ii].te_ptext); X fix_str(&rs_tedinfo[ii].te_ptmplt); X fix_str(&rs_tedinfo[ii].te_pvalid); X } X} X Xstatic void fix_frstr() X{ X int ii; X X for (ii = 0; ii < NUM_FRSTR; ii++) X fix_str(&rs_frstr[ii]); X} X Xstatic void fix_img(where) Xlong *where; X{ X if (*where != NIL) X *where = (long) (char *) rs_imdope[(int) *where].image; X} X Xstatic void fix_iconblk() X{ X int ii; X X for (ii = 0; ii < NUM_IB; ii++) X { X fix_img(&rs_iconblk[ii].ib_pmask); X fix_img(&rs_iconblk[ii].ib_pdata); X fix_str(&rs_iconblk[ii].ib_ptext); X } X} X Xstatic void fix_bitblk() X{ X int ii; X X for (ii = 0; ii < NUM_BB; ii++) X fix_img(&rs_bitblk[ii].bi_pdata); X} X Xstatic void fix_bb(where) Xlong *where; X{ X if (*where != NIL) X *where = (long) (char *) &rs_bitblk[(char) *where]; X} X Xstatic void fix_frimg() X{ X int ii; X X for (ii = 0; ii < NUM_FRIMG; ii++) X fix_bb(&rs_frimg[ii]); X} X X X/* this is the only 'exported' function in X * this module. X */ Xvoid rsc_fix() X{ X fix_trindex(); X fix_objects(); X fix_tedinfo(); X fix_iconblk(); X fix_bitblk(); X fix_frstr(); X fix_frimg(); X} X X#undef adj SHAR_EOF if test 7544 -ne "`wc -c 'rcsfix.c'`" then echo shar: error transmitting "'rcsfix.c'" '(should have been 7544 characters)' fi # End of shell archive exit 0 -- usenet: .....!decvax!cwruecmp!bammi jwahar r. bammi csnet: bammi@case arpa: bammi%case@csnet-relay compuServe: 71515,155