home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22053 < prev    next >
Encoding:
Text File  |  1993-01-24  |  2.2 KB  |  75 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!usc!sdd.hp.com!saimiri.primate.wisc.edu!relay!relay2!afterlife!mssmith
  3. From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
  4. Subject: Question about bit manipulation
  5. Message-ID: <1993Jan24.023728.5051@afterlife.ncsc.mil>
  6. Organization: The Great Beyond
  7. Date: Sun, 24 Jan 1993 02:37:28 GMT
  8. Lines: 65
  9.  
  10. Hi!  I'm working on a library of routines for doing direct-screen graphics
  11. on the Mac..  One thing I'm concentrating on right now is my own "masking"
  12. routines, so that the background can shine through areas of "sprites"
  13. (pictures) that are specially marked.
  14.  
  15. Basically, I write to the screen by doing something like this:
  16.  
  17.   long *long_ptr;
  18.  
  19.   long_ptr = (address of memory location representing part of screen to draw to)
  20.  
  21.   *long_ptr = 0xaaaaaaaa;
  22.  
  23.    The way I have this set up, four pixels would be written to the screen,
  24. each of color "aa" -- aa, or 170 in base-10, represents the color defined
  25. in my CLUT as entry 170 (out of 256).  So, say that entry was blue -- I would
  26. have four horizontal blue pixels plotted on the screen.
  27.  
  28.    All works well.  I have developed a system for converting pictures into
  29. this format, so I can easily (and VERY quickly!) plot these pictures on screen.
  30. But, now I want to replace all "00"'s with the color from the background at
  31. that location..  If that makes sense.
  32.  
  33. So, if the first four pixels of the screen look like this:
  34.  
  35. a1a1a1a1
  36.  
  37. And I want to plot a "ee0000ee" on the screen, I would want the result to be:
  38.  
  39. eea1a1ee
  40.  
  41. I hope that makes sense..  Now, the way that I'm attacking this, is to basically
  42. bit-or the two together.
  43.  
  44. I.e. "ee0000ee | 00a1a100" should yield "eea1a1ee", which is what I want.
  45.  
  46. But the problem is, Think C doesn't seem to want to deal with long's greater
  47. than four hexadecimal digits..  That is, if I do:
  48.  
  49.   printf("%x\n", 0xffffffff);
  50.  
  51. It prints:
  52.  
  53.   ffff
  54.  
  55. And so forth..
  56.  
  57. My questions are: (1) why? (2) how can I fix/work around this?
  58.  
  59. Now that I go back and fool around, I'm getting unusual results for the
  60. following:
  61.  
  62.   unsigned long int junk = 4147483645;
  63.  
  64.   printf ("[%ld]\n", junk);
  65.  
  66. It prints out "-147483651"..
  67.  
  68. Am I missing something that's obvious?
  69.  
  70. Thanks in advance for any help..
  71.  
  72. M. Scott Smith
  73.   (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
  74.  
  75.