[comp.sys.apple] Another twist on getting a catalog into a file

rjchen@phoenix.Princeton.EDU (Raymond Juimong Chen) (01/30/89)

Here's a trick which, when I took apart a program that did it, had
me in awe.  Here's what you do:

Reserve a block of memory large enough to hold your catalog.
(For the sake of example, say it is $4000--$6000.  8K for a catalog
seems reasonable.)

Out on page 3, write the following machine-language program:

cout: sty ysave ; I forget the actual place.  Something like $35
      ldy #0
      sta (6),y
      inc 6
      bne *+2
      inc 7
      ldy ysave
      rts

keyin: sta (base),y ; The screen base pointer.  I forget its actual value.
		; disassemble the normal keyin or look in your copy of
		; the monitor ROMs.
	lda #$a0 ; space
	rts

(Note:  It helps if you have the old Apple ]['s since they came with
 the complete monitor ROM source code, so you know which zero page locations
 do what.)

After setting this up, store into (6,7) a pointer to your buffer,
in this case, you store (0,64).  Then set $(36,37) to point to cout,
and $(38,39) to point to keyin, call $3ea to tell DOS about the new
output and input handlers.

Now execute your catalog.  It will get stored into memory instead
of appearing on the screen.  The bogus keyin routine hits the space
bar for you, in case it's more than one screenful.

Afterwards, do a pr#0, in#0, call $3ea to reset the output and input
pointers.

Now, your catalog is in memory starting at $4000, and ending at whatever
(6,7) is pointing at.  Do with it as you please.  (The program I was
inspecting parsed the stuff so it could do one of those bounce-bar
menu-things with your catalog.)

[Actually, you could have done anything which sends output to the
screen, and it'll show up in your buffer.  Minor modifications to
this method can be used to, say, make a transcript of your session.]

(I'd say we've beaten this topic to death now, don't you?)

-- 
Raymond Chen	UUCP: ...allegra!princeton!{phoenix|pucc}!rjchen
		BITNET: rjchen@phoenix.UUCP, rjchen@pucc
		ARPA: rjchen@phoenix.PRINCETON.EDU, rjchen@pucc.PRINCETON.EDU
"Say something, please!  ('Yes' would be best.)" - The Doctor