
On Sat, 9 Nov 2002, rtk wrote:

> Date: Sat, 09 Nov 2002 15:15:19 -0700
> From: rtk <rkneusel@qwest.net>
> Newsgroups: comp.sys.apple2.programmer, comp.sys.apple2
> Subject: Apple Pascal, how to save the graphics screen?
>
> Does anyone know of a simple way to get the hires graphics screen to a
> file
> in Apple Pascal 1.3?
>
> If I could get the data into a packed character array then it could be
> written
> with BLOCKWRITE.  The question is, how to get the data in there?
>
> Is there a function similar to PEEK that I've missed?  Any pointers
> appreciated!
>
> Ron Kneusel
> oneelkruns@hotmail.com  <-- best email address
>
Hi,

In my old book about Apple Pascal, I've found two procedures that might help
you:

PROCEDURE savepic(filename : STRING);
  VAR
    f		: FILE;
    address, n	: INTEGER;
    ptr		: ^INTEGER;
BEGIN
  address := 8192; (* address of hiresscreen page 1 *)
  moveleft(address, ptr, 2); (* copy address value into pointer *)
  rewrite(f, filename);
  n := blockwrite(f, ptr^, 16); (* save 16 blocks from 8192 to 16383 *)
  close(f, lock);
END;

PROCEDURE loadpic(filename : STRING);
  VAR
    f		: FILE;
    address, n	: INTEGER;
    ptr		: ^INTEGER;
BEGIN
  address := 8192;
  moveleft(address, ptr, 2);
  reset(f, filename);
  n := blockread(f, ptr^, 16);
  close(f);
END;

Please note: This way, you are also storing all the unnecessary screenholes,
but it is probably the fastest and easiest way to store a picture on disk.
Another important thing: If you are using Turtlegraphics at the same time,
there might be some trouble. It's been a very long time, so I don't remember
this correctly anymore and I may be wrong anyway. It's just when I used
assembler to clear the screen (i.e. clearing the memory from $2000 - $3fff)
I noticed that Turtlegraphics didn't work properly anymore (Apple Pascal
1.1). My guess then was that Turtlegraphics uses the screenholes to store
things like the last coordinates and angle for the MOVE-statement etc. Now,
if you want to reload a picture this way, it is possible that you overwrite
these values with some old ones stored within the picture. Well, just have a
try and see what happens.

Kindest regards

  Holger



