[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PEEKing in Apple Pascal
"rtk" <rkneusel@qwest.net> wrote in message
3DCD88F7.F100F802@qwest.net">news:3DCD88F7.F100F802@qwest.net...
> 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
I assume "Any pointers appreciated!" wasn't meant to be a pun.
But they (pointers) are the key.
I used to program in Pascal 20 years ago and don't remember it very well.
But I have some notes which might help.
I don't have Apple Pascal version 1.3, but I have 1.0, 1.1, and 1.2 and
assume 1.3 isn't that much different.
I wanted a "Keypress" function without having to used SYSTEM.LINKER to link
in an assembly language KEYPRESS routine from the SYSTEM.LIBRARY. Trying to
do Pascal on one 5.25 drive was a real challenge.
Here is the code I used which provided me with a KEYPRESS function with the
equivalent of PEEK.
function keypress: boolean;
type pk = packed array[0..1] of 0..255;
byte = record
case integer of
1: (int:integer);
2: (ptr:^pk)
end;
var addr,rptr,wptr,kybd: integer;
peek: byte;
begin
addr := -16616; (* rptr *)
peek.int := addr;
rptr := peek.ptr^[0];
addr := -16615; (* wptr *)
peek.int := addr;
wptr := peek.ptr^[0];
addr := -16384; (* keyboard *)
peek.int := addr;
kybd := peek.ptr^[0];
keypress := ((rptr<>wptr) or kybd>127));
end;
The pointer (^) is a way to access the physical location of a variable.
Change where a pointer points and you can access a specific memory location.
Doing a keypress wasn't as simple as peeking at the keyboard because the
Pascal BIOS kept scanning for keys and putting them in an input buffer. rptr
and wptr were BIOS variables tracking this buffer. It's possible they are no
longer at the same place in Pascal 1.3, but the technique for PEEKing should
still work.
I hope you can follow the code, because I know longer understand it.
I'm sure there was a program published in Call Apple or maybe the IAC's
magazine that told exactly how to save a hires screen to disk (even using
the defined but never used .FOTO file type).
You don't have to peek the whole screen and put it in an array. In Pascal
that would probably take a while.
Instead you define an array and adjust the pointer to it to point to screen
memory.
Something like
type hrscreen = packed array[0..8191] of 0..255;
byte = record
case integer of
1: (int:integer);
2: (ptr:^hrscreen)
end;
var addr: integer;
peek: byte;
myscreen: hrscreen;
begin
addr := 8192 ; (* or 16384 - does Pascal use page1 or 2 ?*)
peek.int := addr;
myscreen := peek.ptr^[0];
then write the screen array to disk.
I know this is NOT correct, but it's halfway there.
Do a Google search on Apple Pascal pointers for more info.
Hope fully, I have "pointed" you in the right direction.
So somebody is actually programming in Apple Pascal in 2002?
Good luck.
Joel