Newsgroups: comp.sys.mac.programmer Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!psuvax1!swatsun!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Subject: Re: Help with ScrnBase (again) Message-ID: <14CPAYB@cs.swarthmore.edu> Reply-To: jackiw@cs.swarthmore.edu (Nick Jackiw) Organization: Visual Geometry Project, Swarthmore College, PA References: <1990Aug23.172022.20545@murdoch.acc.Virginia.EDU> Distribution: usa Date: Thu, 23 Aug 90 18:59:14 GMT mil@mendel.acc.Virginia.EDU (Maria I. Lasaga) writes: > Can anyone tell me why the following code bombs? Any clues > would be appreciated. DISCLAIMER: I've never played with ScrnBase and don't, off the top of my head, know how to do it. The following observations are "clues"--not answers. > > var > oldport: grafptr; > offscreen: grafport; > mypointer: ptr; "Ptr" is defined in the Memory Manager as ^SignedByte. You are trying to stuff either a word or a longword into myPointer. Depending on your compiler, you may just be sticking the low-order byte of this word or longword into myPointer^. Try instead declaring myPointer as either ^longint or ^integer, depending on whether you want to write four bytes or two. > mybitmap: bitmap; > myaddress: longint; > > begin > > {--offscreen bitmap created here--} > > > eraserect(theport^.portrect); { clearing the area of memory... } > > myaddress := $727; {starting location for alternate memory buffer on SE} > mybitmap.baseaddr := @myaddress; I highly doubt that location $727 is the base address of an alternate memory buffer. Why? Because a B&W 9" screen is about 20K worth of data, and the area between $727 and $727+20K is filled with important low-memory globals. Not exactly information you want to be drawing pictures over. Could location $727 *contain* the address of the alternate screen buffer? If so, you'll want to set myBitmap.baseAddr to longintPtr($727)^, instead of to $727 itself. > mybitmap.rowbytes := offscreen.portbits.rowbytes; > mybitmap.bounds := offscreen.portbits.bounds; > copybits(offscreen.portbits, mybitmap, > offscreen.portrect, offscreen.portrect, srccopy, nil); > > {copies an image previously drawn in an offscreen portrect} > > myaddress := $824; {supposedly the location of the global variable,} > {ScrnBase, that holds the address of the main screen } > {buffer. } > > mypointer := @myaddress; > mypointer^ := $727; {Attempt to set ScrnBase to the address of the } > {alternate screen buffer.} > end; This stuff is wrong for the above reasons. You're setting location $824 to value $727, and I suspect you want to set location $824 to value of location $727. If not, as soon as you write data, the 20K following location $727 is going to be scrambled--including, of course, location $824. Hope this puts you on the right track. -- ------------------------ Nick Jackiw jackiw@cs.swarthmore.edu "Just break out the Visual Geometry Project jackiw@swarthmr.bitnet rum so we seem natural!" Swarthmore College, PA 19081-1397 -F. Franklin