[net.micro.atari] RSC dump program for ST

turner@imagen.UUCP (D'arc Angel) (02/05/86)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ lineater, \~~~~~~~~~~~~~~~~~~~~~~~~~

this is a program i wrote when i was first learning the ST, it gives
an ascii description of a resource file created with the resource
editor. To use it you need both the .C and .H files from the editor,
these are gotten by (if memory serves me correctly) selecting the
'save source' option from the menu. You should replace the #include
for flibs.h and flibs.c with your own and recompile the program. It
was written to run under 4.2BSD but should run on the ST. Please
send all bug reports to me, flames to /dev/null.


#include "stdio.h"
#include "obnames.h"
#include "portab.h"
#include "obdefs.h"
/************************************************************************/
/*                                                                      */
/* INCLUDE the 2 files created by saving source from the resource       */
/*  editor after this comment. For example:                             */
/*                                                                      */
/************************************************************************/
#include "flibs.c"
#include "flibs.h"

main()

{
	int i,j,k;
	char buf1[24],buf2[24],buf3[24],buf4[24];

	printf("************Resource File %s****************\n\n",pname);
	for(i=0; i<NUM_OBS; i++) {
		printf("***OBJECT BLOCK #%d\nnext sibling=%d, children: head=%d, tail=%d\n",
			i,rs_object[i].ob_next,rs_object[i].ob_head,rs_object[i].ob_tail);
		for(j=0; obtype_names[j].text != '\0'; j++) {
			if(rs_object[i].ob_type == obtype_names[j].value) {
				strcpy(buf1,obtype_names[j].text);
				break;
			}
		}
		for(j=0; obflag_names[j].text != '\0'; j++) {
			if(rs_object[i].ob_flags == obflag_names[j].value) {
				strcpy(buf2,obflag_names[j].text);
				break;
			}
		}
		for(j=0; obstate_names[j].text != '\0'; j++) {
			if(rs_object[i].ob_state == obstate_names[j].value) {
				strcpy(buf3,obstate_names[j].text);
				break;
			}
		}
		printf("type=%s, flags=%s, state=%s\nspec=%lx (",
			buf1,buf2,buf3,rs_object[i].ob_spec);
		switch(rs_object[i].ob_type) {
			case G_BOX:
			case G_IBOX:
			case G_BOXCHAR:
			k = rs_object[i].ob_spec & 0x0000ffffL;
			dump_color(k);
			if(rs_object[i].ob_type == G_BOXCHAR)
				printf("char=%c,",(rs_object[i].ob_spec & 0xff000000L) >> 24);
			k = (rs_object[i].ob_spec & 0x00ff0000) >> 16;
			if(k == 0)
				printf("no border,");
			else if(k > 128)
					printf("inside border=%d,",(256-k));
				else
					printf("outside border=%d,",k);
			break;
		 case G_TEXT:
		 case G_BOXTEXT:
		 case G_FTEXT:
		 case G_FBOXTEXT:
			printf(" ");
			break;
		case G_BUTTON:
		case G_STRING:
		case G_TITLE:
			printf("text='%s'",rs_strings[rs_object[i].ob_spec]);
			break;
		} /* end switch */
		printf(")\n");
		printf("x=%d, y=%d, width=%d, height=%d\n\n",
			rs_object[i].ob_x,rs_object[i].ob_y,rs_object[i].ob_width,
			rs_object[i].ob_height);
	}
}
dump_color(color)
int color;

{
	int bcolor,tcolor,trans,fill,icolor;

	bcolor = (color & 0xf000) >> 12;
	tcolor = (color & 0x0f00) >> 8;
	trans  = (color & 0x0080) >> 7;
	fill   = (color & 0x0070) >> 4;
	icolor = (color & 0x000f);

	printf("colors: border=%s,text=%s,inside=%s; mode=%d, fill=%d\n",
	 obcolor_names[bcolor],obcolor_names[tcolor],obcolor_names[icolor],
	 trans,fill);

}

-- 
----
			god bless Lily St. Cyr
			 -Rocky Horror Picture Show

Name:	James Turner
Mail:	Imagen Corp. 2650 San Tomas Expressway, P.O. Box 58101
        Santa Clara, CA 95052-9400
AT&T:	(408) 986-9400
UUCP:	...{decvax,ucbvax}!decwrl!imagen!turner
CompuServe: 76327,1575