home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!usc!sdd.hp.com!saimiri.primate.wisc.edu!relay!relay2!afterlife!mssmith
- From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
- Subject: Question about bit manipulation
- Message-ID: <1993Jan24.023728.5051@afterlife.ncsc.mil>
- Organization: The Great Beyond
- Date: Sun, 24 Jan 1993 02:37:28 GMT
- Lines: 65
-
- Hi! I'm working on a library of routines for doing direct-screen graphics
- on the Mac.. One thing I'm concentrating on right now is my own "masking"
- routines, so that the background can shine through areas of "sprites"
- (pictures) that are specially marked.
-
- Basically, I write to the screen by doing something like this:
-
- long *long_ptr;
-
- long_ptr = (address of memory location representing part of screen to draw to)
-
- *long_ptr = 0xaaaaaaaa;
-
- The way I have this set up, four pixels would be written to the screen,
- each of color "aa" -- aa, or 170 in base-10, represents the color defined
- in my CLUT as entry 170 (out of 256). So, say that entry was blue -- I would
- have four horizontal blue pixels plotted on the screen.
-
- All works well. I have developed a system for converting pictures into
- this format, so I can easily (and VERY quickly!) plot these pictures on screen.
- But, now I want to replace all "00"'s with the color from the background at
- that location.. If that makes sense.
-
- So, if the first four pixels of the screen look like this:
-
- a1a1a1a1
-
- And I want to plot a "ee0000ee" on the screen, I would want the result to be:
-
- eea1a1ee
-
- I hope that makes sense.. Now, the way that I'm attacking this, is to basically
- bit-or the two together.
-
- I.e. "ee0000ee | 00a1a100" should yield "eea1a1ee", which is what I want.
-
- But the problem is, Think C doesn't seem to want to deal with long's greater
- than four hexadecimal digits.. That is, if I do:
-
- printf("%x\n", 0xffffffff);
-
- It prints:
-
- ffff
-
- And so forth..
-
- My questions are: (1) why? (2) how can I fix/work around this?
-
- Now that I go back and fool around, I'm getting unusual results for the
- following:
-
- unsigned long int junk = 4147483645;
-
- printf ("[%ld]\n", junk);
-
- It prints out "-147483651"..
-
- Am I missing something that's obvious?
-
- Thanks in advance for any help..
-
- M. Scott Smith
- (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
-
-