home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!apple!mumbo.apple.com!gallant.apple.com!nuntius
- From: Ed Rotberg <gonzo@ntb.apple.com>
- Subject: Re: date on the mac
- Sender: news@gallant.apple.com
- Message-ID: <1992Nov19.212748.18994@gallant.apple.com>
- X-Useragent: Nuntius v1.1
- Date: Thu, 19 Nov 1992 21:27:48 GMT
- References: <BxxJ6A.KHw@mentor.cc.purdue.edu>
- Organization: Apple Computer
- Lines: 63
-
- larsel@ifi.uio.no (Lars Yngvar Ellingsen)
-
-
- In article <1992Nov19.014824.4747@ifi.uio.no> Lars Yngvar Ellingsen,
- larsel@ifi.uio.no writes:
- >(The routine is supposed to write a row of pixels from position x,y with
- >one specific value on the screen in 8-bits color.)
- >(I'm extremely inexperienced with both C and asm so forgive my stupid
- >blunders :)
- >
- >main()
- >{
- > GDHandle theDevice;
- > unsigned char *color;
- > long *address;
- > short x,y,*width;
- > unsigned int color;
- >
- > theDevice = GetMainDevice();
- >
- > // do stuff; assign values to x, y, color and width
- >
- > &address = &(*(**(**theDevice).gdPMap).baseAddr)+
- > (long)y*SCREENWIDTH+(long)x;
- > asm {
- > @Main: move.b color,d1
- > move.w width,d2
- > movea.l address,a1
- > @Loop: move.b d1,(a1)+
- > dbra d2,@Loop
- > rts
- > }
- >}
- >
- >What am I doing wrong?
-
-
- Notice how you are using the pointer variable "address"? You are moving
- it
- into an address register and writing indirect through it. Also note that
- both color and width are also pointer variables, but you are accessing
- them
- as though they are not! The simplest fix to the above code would be:
-
- @Main: movea.l color,a1 ; pick up pointer to desired
- fill color
- move.b (a1),d1 ; pick up desired fill
- color
- movea.l width,a1 ; pick up pointer to line width
- move.w (a1),d2 ; pick up line width
-
- instead of:
-
- > @Main: move.b color,d1
- > move.w width,d2
-
-
- This of course assumes that color and width should INDEED be pointer
- variables.
-
- Ed Rotberg "Just remember...
- Professor of Gonzo a waist is a terrible
- Apple Computer, Inc. thing to mind"
-