[comp.sys.amiga] Great Program on BBS

dillon@CORY.BERKELEY.EDU.UUCP (02/27/87)

	Dale just informed me that the workbench screen sizing program was
written by Neil Katin.

				Thanks Neil!

				-Matt

papa@bacall.UUCP (02/28/87)

Well, probably by now other people have found out how morerows works, but
here it is anyway.  Morerows uses an "undocumented", and I understand
unsupported, feature of the Preferences structure.  Preferences stores its 
data in the :devs/system-configuration file.  I compared the file before and
after having executed "morerows -rows 35 -columns 64". The files are 
identical besides 2 bytes, which have the appropriate values 35 and 64
(23 and 40 in hex). This is the binary hex output from "od" on my favourite
UNIX BSD system:

0000000  0008 0500 0000 0000 0100 a086 0000 0000
0000020  0c00 0035 0000 0100 0700 20a1 0000 0000
0000040  0000 00fc 007c 00fe 007c 0086 0078 008c
0000060  007c 0086 006e 0093 0007 8069 8003 c004
0000100  c001 6002 8000 4001 0000 8000 0000 0000
0000120  0000 0000 0000 0000 0000 0000 0000 0000
0000140  0000 0000 fffe 220d 0000 ca0f 0200 5a00
0000160  ff0f 0200 800f 0000 8100 2c00 0100 0000
0000200  4243 5f4d 504d 3153 3030 0030 0000 0000
0000220  0000 0000 0000 0000 0000 0000 0000 0000
0000240  0000 0000 0500 4b00 0100 0000 0100 0200
0000260  2000 4200 0000 0000 0000 0000 0000 0000
0000300  0000 0000 0000 0000 0000 0000 0000 0000
0000320  0000 0000 0000 0000 4023 0000 0000 0000 <------ This is it!
0000340  0000 0000 0000 0000
0000350

It looks as if the system-configuration file has an almost one to one
correspondence with the Preferences structure from intuition.h.  Whenever
one executes a SAVE of Preferences, the system-configuration file gets
rewritten with the new Preferences data.

The bytes with value 40 and 23 are located in the padding area at the end of 
the Preferences structure.  After some experimentation, I found that those
values are stored in padding[34] and padding[35].  The following is a
reinterepretation of the original "morerows" by Neil Katin.  Now, is this 
going to be a "supported" feature in the future?  I'd love to see that.
It is things like these that me me really love the Amiga.  At the Developer's 
Conference the notes mentioned the "magic program morerows (poof!)".  Why
was this feature implemented, not documented, advertised and never really
distributed, I don't know.

Note that I have not tested this with incorrect values (like col > 64), so 
use this at your own risk. How about posting the original source by Neil
Katin? I did not really write this one, just reverse-engineered it.

Enjoy.

-- Marco Papa

/*
 * mymorerows.c
 * Marco Papa - Felsina Software
 * ...!sdcrdcf!bacall!papa
 */

#include <exec/types.h>
#include <intuition/intuition.h>

#define INTUITION_REV 1L

struct IntuitionBase *IntuitionBase;

main(argc, argv)
int argc;
char *argv[];
{
	struct Preferences *PrefBuffer;
	char *malloc();
	BYTE  rowsizechange, columnsizechange;

	IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", INTUITION_REV);
	if( IntuitionBase == NULL ) {
		puts("Can't open intuition library");
		exit(TRUE);
	 }

	 PrefBuffer = (struct Preferences *) malloc((unsigned) sizeof(struct Preferences)+20);

	 GetPrefs(PrefBuffer, (long) sizeof(struct Preferences)+20);

	 if (argc>2) {
	 	rowsizechange = atoi(argv[1]);
		columnsizechange = atoi(argv[2]);

		PrefBuffer->padding[34] = rowsizechange;  /* 35 */
		PrefBuffer->padding[35] = columnsizechange; /* 64 */
		SetPrefs(PrefBuffer, (long) sizeof(struct Preferences)+20, TRUE);
	 } else {
	 	printf("current rowsizechange = %d\n", (int) PrefBuffer->padding[34]);
		printf("current columnsizechange = %d\n", (int) PrefBuffer->padding[35]);
	 }

	 free(PrefBuffer);
	 CloseLibrary(IntuitionBase);
}