home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15353 < prev    next >
Encoding:
Text File  |  1992-09-11  |  3.4 KB  |  68 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!gumby!kzoo!k044477
  3. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  4. Subject: Re: simulating page-flipping via cluts
  5. Message-ID: <1992Sep11.163135.28084@hobbes.kzoo.edu>
  6. Organization: Kalamazoo College
  7. References: <18ja83INNk53@agate.berkeley.edu> <1992Sep10.182147.25618@hobbes.kzoo.edu> <1992Sep11.030344.1@vax1.umkc.edu>
  8. Date: Fri, 11 Sep 1992 16:31:35 GMT
  9. Lines: 57
  10.  
  11. tmaehl@vax1.umkc.edu writes:
  12. >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  13. >
  14. >> If you're clut-flipping to simulate page-flipping,
  15. >> [you need every single color]
  16. >
  17. >Two questions: How do you simulate page-flipping with clut-flipping??
  18. >
  19. >And second: Wouldn't this fail to accomplish anything at all on
  20. >a direct color screen, or am I *completely* misunderstanding (a
  21. >distinct possibility.)
  22.  
  23. The easy one first:  yes, clut-flipping does nothing on a direct-color
  24. screen.  In fact, a direct-color screen doesn't even have a color table
  25. to flip.
  26.  
  27. Clut flipping is a nasty little technique that lets you pretend you have
  28. two video pages, each of which has half as many bits per pixel as the
  29. real video page.  In short, you split each pixel in half, and alternate
  30. between setting the clut so that one half is visible and the other half
  31. not.  An example might help clarify.
  32.  
  33. Let's say we're working on an 8-bit-deep screen.  Conceptually, split
  34. each pixel into two 4-bit halves, call them left and right.  To set the
  35. pixel at x,y on the left video page to, say, color 7, you set the high
  36. four bits of the actual pixel at x,y to 7, without disturbing the low
  37. four bits.  To set the pixel on the right video page to color 4, you set
  38. the low four bits to 4 without disturbing the high four bits.
  39.  
  40. Let's say the palette we're using is sixteen shades of gray.  (Note that
  41. you only get sixteen colors, since each page gets only four bits per
  42. pixel.  Note also that you can have different palettes for the left and
  43. the right page, and that there's actually a good use for that:  there
  44. are glasses that sync to your monitor that use LCD shutters to give a
  45. decent 3-D effect.  But I digress.)  Then, to display the left page, you
  46. set colors 0x00-0x0F to black, 0x10-0x1F to dark gray, ... , 0xF0-0xFF
  47. to white.  To display the right page, you set 0x00, 0x10, ... 0xF0 to
  48. black, 0x01, 0x11, ... 0xF1 to dark gray, and so on.
  49.  
  50. Note that you don't have to use hi-nybble/lo-nybble for left and right
  51. pages;  you can split up the pixel any way you want.  It doesn't even
  52. have to be an even split, and you can split it as many ways as there are
  53. bits in the pixel in the first place.  If you don't mind having only two
  54. colors and seeing the same eight frames over and over, you can do
  55. eight-position full-screen animation at whatever your monitor's refresh
  56. rate is, using just a tiny fraction of CPU power.
  57.  
  58. Note also that, if the palette(s) for your virtual pages all have all
  59. their bits clear for white and all their bits set for black, you can
  60. leave those two colors where they are, and the Palette Manager will be
  61. usable.  (Though I'll concede that there's no good reason not to use
  62. SetEntries instead of AnimatePalette when you're getting this
  63. low-level...)
  64. -- 
  65.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  66.  "I may not understand what you say, but I'll defend to your death
  67.   my right to deny it."                 - Albert, from 'Outrageously Pogo'
  68.