[comp.sys.amiga] DumpCat.rexx

gergref@dhw68k.cts.com (Bryan Ford) (09/20/90)

>Try writing the IFF file to the RAM disk to see if it makes any difference.
>Also, if you are rendering at 320x400 (or higher) try rendering at 319x400.
>To simplify things in Ham, I kept the left border black, so you really only
>have 319 pixels across.

Is this really necessary?  As I remember, all HAM scanlines always start at
the background color at the beginning of each scan line.  Please, someone
tell me if I'm wrong.

Now for a (hopefully) useful little ARexx script I put together while I was
trying to raytrace 'roman.data' - It took my computer about 4 days, 24 hours
a day to raytrace and, since I couldn't possibly keep my hands off the         
computer during that time, I had a few GURU's and had to trace the thing in
like eight different sessions.  (Beautiful picture, BTW!)  Anyway, I ended
up with a bunch of separate .dis files which couldn't be simply concatenated
together, because DumpToIff would crash on me.  So I made this script... It
doesn't just concatenate the files, it creates a destination file with all
the scanlines in the right order, and removes any duplicated scanlines.  It
also tells you if any scanlines are missing.

Have fun!
				Bryan

P.S. The command 'RX DumpCat ?' will get the usage and documentation.

/*
DumpCat.rexx - Combines DKBTrace/QRT Dump files

Public Domain by Bryan Ford

Usage: RX DumpCat <basename>

This script takes several Dump files from DKBTrace or QRT (from several
tracing sessions) and combines them into a single dump file.  Each of the
source files must be of the format "<basename><n>.dis" where <n> is a
decimal number.  This program searches for "<basename>1.dis" then
"<basename>2.dis", then "<basename>3.dis", until it can't find one with
that name, so the file numbers must be continuous.  It writes an output
file of the name "<basename>.dis", and if it already exists, it will be
overwritten, so make sure this is not the name of one of your source files.

This script does not simply concatenate the files, as the title indicates,
but actually reads each one into memory and writes them all out in the
proper order.  Therefore, there must be enough memory to hold the entire
destination dump file.  However, the memory doesn't have to be contiguous
or chip memory.  The width and height of the image are taken from the first
source file, and they must be the same in all the other source files.

If any scanlines are missing in all the source files, this script will tell
you exactly which ones are missing in the output phase, so you know what
you still need to get a complete picture.

Note that I haven't tried this with QRT, but the DKBTrace documentation says
that its dump files are compatible with QRT, and since the actual file format
is very simple, I'll trust the documentation.

This script is placed in the public domain.  Therefore you can legally do
anything you want with it.  However, I'd appreciate it if you'd leave my
name in it.

Have Fun!

	Bryan Ford
	P.O. Box 50201
	Provo, UT 84605-0201
	(801) 375-8992

P.S.  Thanks to Bill Hawes for providing an excellent implementation of the
ARexx languags!
*/

parse arg basename .

/* Usage message */
if (basename = '?') | (basename = '') then
	do
		i = 2
		do forever
			str = sourceline(i)
			if str = '*/' then break
			say str
			i = i + 1
		end
		exit(0)
	end

/* Open the first source file */
counter = 1
if ~open(inhand,basename||counter||".dis",'R') then
	do
		say "Can't open file "basename||counter||".dis"
		exit(10)
	end

/* Open the output file */
if ~open(outhand,basename".dis",'W') then
	do
		say "Can't open output file "basename".dis"
		exit(10)
	end

/* Copy the file header - the width and height of the image */
header = readch(inhand,4)
writech(outhand,header)

/* Find the number of scanlines and the number of bytes per scanline */
/* Note that all numbers are backwards, screwy, weird, reverse byte-ordered
	MS-DOS style numbers, so we have to read each byte separately. */
say ''
width = c2d(substr(header,1,1)) + c2d(substr(header,2,1))*256
say 'Width:' width
scanbytes = width * 3 + 2
lines = c2d(substr(header,3,1)) + c2d(substr(header,4,1))*256
say 'Height:' lines

/* Initialize all lines to empty */
do i = 0 to lines-1
	scandata.i = ''
end

/* Read all the source files */
do forever
  say ''
	say "Reading file "basename||counter".dis"
	
	/* Read the scanlines in one source file */
	do until length(instr) ~= scanbytes
		instr = readch(inhand,scanbytes)
		if length(instr) = scanbytes then
			do
				scanline = c2d(substr(instr,1,1)) + c2d(substr(instr,2,1))*256
				say ' Scanline' scanline
				scandata.scanline = instr
			end
	end
	
	counter = counter + 1
	close(inhand)
	if ~open(inhand,basename||counter||".dis",'R') then
		leave
	header = readch(inhand,4)
end

say ''
say 'Writing output file...'

/* Write the output file */
do i = 0 to lines-1
	if scandata.i = '' then
		say 'Warning: Scanline' i 'is missing!'
	else
		/* I decided not to put a 'Scanline x' message here so the user doesn't
			easily miss any 'Scanline x is missing' messages. */
		call writech(outhand,scandata.i)
end

dbuck@ccs.carleton.ca (Dave Buck) (09/22/90)

In article <1990Sep20.005428.18283@dhw68k.cts.com> gergref@dhw68k.cts.com (Bryan Ford) writes:
>Now for a (hopefully) useful little ARexx script I put together while I was
>trying to raytrace 'roman.data'.
> [stuff deleted]
>So I made this script... It
>doesn't just concatenate the files, it creates a destination file with all
>the scanlines in the right order, and removes any duplicated scanlines.  It
>also tells you if any scanlines are missing.
>
>Have fun!
>				Bryan
>
>P.S. The command 'RX DumpCat ?' will get the usage and documentation.

Thanks for the utility.  I'll include it in future releases of DKBTrace.
I would like to have a C program that does the same thing, though, so it
can be used by the UNIX and IPC PC folks.  One of these days when I get
some time I'll write it.  Thanks for your effort.  I know a lot of people
using Amiga's who have been asking for a utility like this.

David Buck
dbuck@ccs.carleton.ca
-- 
_____________________________________________________________________
| David Buck                    | My employer is not responsible for|
| dbuck@ccs.carleton.ca         | my opinions.  I'm not even sure   |
| David_Buck@carleton.ca        | I am.                             |