home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18674 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.2 KB  |  76 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!apple!mumbo.apple.com!gallant.apple.com!nuntius
  3. From: Ed Rotberg <gonzo@ntb.apple.com>
  4. Subject: Re: date on the mac
  5. Sender: news@gallant.apple.com
  6. Message-ID: <1992Nov19.212748.18994@gallant.apple.com>
  7. X-Useragent: Nuntius v1.1
  8. Date: Thu, 19 Nov 1992 21:27:48 GMT
  9. References: <BxxJ6A.KHw@mentor.cc.purdue.edu>
  10. Organization: Apple Computer
  11. Lines: 63
  12.  
  13. larsel@ifi.uio.no (Lars Yngvar Ellingsen)
  14.  
  15.  
  16. In article <1992Nov19.014824.4747@ifi.uio.no> Lars Yngvar Ellingsen,
  17. larsel@ifi.uio.no writes:
  18. >(The routine is supposed to write a row of pixels from position x,y with 
  19. >one specific value on the screen in 8-bits color.)
  20. >(I'm extremely inexperienced with both C and asm so forgive my stupid 
  21. >blunders :)
  22. >
  23. >main()
  24. >{
  25. >  GDHandle    theDevice;
  26. >  unsigned char *color;
  27. >  long          *address; 
  28. >  short         x,y,*width;
  29. >  unsigned int  color;
  30. >   
  31. >  theDevice = GetMainDevice();
  32. >
  33. >  // do stuff; assign values to x, y, color and width
  34. >  
  35. >  &address = &(*(**(**theDevice).gdPMap).baseAddr)+
  36. >             (long)y*SCREENWIDTH+(long)x;
  37. >  asm {
  38. >    @Main:   move.b    color,d1
  39. >             move.w    width,d2
  40. >             movea.l   address,a1
  41. >    @Loop:   move.b    d1,(a1)+
  42. >             dbra      d2,@Loop
  43. >             rts         
  44. >  }
  45. >}
  46. >
  47. >What am I doing wrong?
  48.  
  49.  
  50. Notice how you are using the pointer variable "address"?  You are moving
  51. it
  52. into an address register and writing indirect through it.  Also note that
  53. both color and width are also pointer variables, but you are accessing
  54. them
  55. as though they are not!  The simplest fix to the above code would be:
  56.  
  57. @Main:  movea.l    color,a1               ; pick up pointer to desired
  58. fill color
  59.             move.b     (a1),d1                 ; pick up desired fill
  60. color
  61.                       movea.l    width,a1              ; pick up pointer to line width
  62.             move.w     (a1),d2                ; pick up line width
  63.  
  64. instead of:
  65.  
  66. >    @Main:   move.b    color,d1
  67. >             move.w    width,d2
  68.  
  69.  
  70. This of course assumes that color and width should INDEED be pointer
  71. variables.
  72.  
  73. Ed Rotberg                 "Just remember...
  74. Professor of Gonzo          a waist is a terrible
  75. Apple Computer, Inc.        thing to mind"
  76.