Article View: comp.sys.mac
Article #16020VBL tasks, offscreen bitmaps, Lightspeed Pascal, etc.
From: Bruce Florman
Date: Thu, 07 May 1987 19:05
Date: Thu, 07 May 1987 19:05
76 lines
3307 bytes
3307 bytes
I'm not a Mac guru by any means, but I've been noodling about with
VBL tasks, PICTs and BitMaps in Lightspeed Pascal for the past few days.
So Peter Wu's and James Moore's postings seemed to be aimed right at me.
pwu@uwmacc.UUCP (Peter Wu) writes:
>According to inside mac a VBL routine need to preserve some registers.
>Is there a way I can do this in pascal? I'm using lightspeed pascal.
>The VBL routine is used to sample data from the serial port at 500ms
>interval.
On entry, a Pascal routine will save all of the necessary registers
automatically except A5. A5 is usually a sacred register, pointing to
the application globals, but since a VBL task is initiated by an
interrupt, A5 may hold some other value. Fortunately the routines
SetUpA5 and RestoreA5 are available (see Inside Macintosh p. II-386).
Just make a call to SetUpA5 on entry to your task and RestoreA5 on exit.
jmm@miro.Berkeley.EDU (James Moore) writes:
>1. How does one get mBarHeight from Lightspeed Pascal?
According to Inside Mac, p I-341, "The menu bar is white, 20 pixels
high, and as wide as the screen, with a 1-pixel black lower border. The
menu titles in it are always in the system font and the system font size."
So it sounds like you can just declare a constant.
>2. I'm having trouble changing bitmaps. I'd like to draw
>off the screen, but I seem to be doing something wrong.
[further description of problem]
>3. I'm having a problem getting PICT resources onto the screen.
[further description of problem]
Here is an excerpt from one of my recent efforts that may (or may
not) help.
procedure AllocateBM (var theBM : BitMap);
{ Using bounds Rect of theBM, AllocateBM calculates the }
{ rowBytes and allocates storage for the appropriate BitImage. }
var
width, height : INTEGER;
begin
with theBM, bounds do
begin
width := right - left;
height := bottom - top;
rowBytes := 2 * ((width + 15) div 16); { the magic formula }
baseAddr := NewPtr(rowBytes * height)
end
end;
procedure GetBM (var theBM : BitMap; id : INTEGER);
{ Given the resource id of a PICT resource, GetBM }
{ allocates a BitMap and draws the picture into it. }
const
PICT = $50494354; { ascii 'P' 'I' 'C' and 'T' }
var
rsrc : PicHandle;
oldBits : BitMap;
begin
rsrc := PicHandle(GetResource(ResType(PICT), id));
with theBM, bounds do
begin
bounds := rsrc^^.picFrame;
OffsetRect(bounds, -left, -top)
end;
AllocateBM(theBM);
oldBits := thePort^.portBits;
SetPortBits(theBM);
DrawPicture(rsrc, theBM.bounds);
SetPortBits(oldBits);
ReleaseResource(Handle(rsrc))
end;
Technical Details
Message-ID:
<971@randvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!hplabs!sdcrdcf!randvax!flormanReferences:
<18736@ucbvax.BERKELEY.EDU>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!hplabs!sdcrdcf!randvax!florman From: florman@randvax.UUCP (Bruce Florman) Newsgroups: comp.sys.mac Subject: VBL tasks, offscreen bitmaps, Lightspeed Pascal, etc. Message-ID: <971@randvax.UUCP> Date: Thu, 7-May-87 15:05:59 EDT Article-I.D.: randvax.971 Posted: Thu May 7 15:05:59 1987 Date-Received: Sat, 9-May-87 19:02:30 EDT References: <18736@ucbvax.BERKELEY.EDU> Organization: Rand Corp., Santa Monica Lines: 76