home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / PMPAL.ZIP / PAL.DOC < prev    next >
Text File  |  1990-03-10  |  5KB  |  113 lines

  1. Color palette change under PM
  2.  
  3. The current versions os OS/2 (1.1 and 1.2) do not support color 
  4. palette change. That is strange, because of the following facts:
  5.  
  6. - On the EGA and VGA cards is is very simple to do that.
  7.  
  8. - In 1987 IBM announced the new PS/2 with a VGA with 16 colors out of 
  9.   a palette with 262144 colors and a new multitasking graphics 
  10.   oriented operating system. The last thing is released two years 
  11.   later, but no choice out of 262144 colors, but just 16 out of 16 
  12.   colors is supported.
  13.  
  14. - There are two system calls called GpiRealizeColorTable(hps) and 
  15.   GpiUnRealizeColorTable(hps), but they do nothing.
  16.  
  17. There are many GIF picture freaks on this BBS and they will miss it. 
  18. I also created a GIF viewer for PM but with support for direct 
  19. palette manipulation through an IOPL routine which writes directly to 
  20. the VGA DACs (VIEWGIF3.ZIP on this BBS), which works on all VGA and 
  21. Super VGAs and (I'm not sure) 8514A. Does somebody know if this 
  22. will change in future versions of OS/2 ? I think the Unix approach is 
  23. much better. With X/Windows the XCreateColormap() function  can
  24. create a color map for an application and when the user switches to 
  25. another application, the physical palette registers are adapted to 
  26. the currently active application automatically, so the inactive 
  27. applications go 'technicolor' (when the current application has a 
  28. different color map than the default X/Windows colors). I used this 
  29. approach with VIEWGIF. 
  30.  
  31. Here is a short description of the routines:
  32. --------------------------------------------
  33.  
  34. The routine OS2PAL.ASM changes EGA and VGA palettes directly.
  35.  
  36. Only direct hardware access works. The documentation in 
  37.  
  38. Richard Wilton: PC & PS/2 Video Systems (Microsoft Press), recommended!
  39.  
  40. is more about BIOS but INT 10 calls are strictly prohibited under OS/2 !! So
  41. I found out how the VGA BIOS worked with Nu Mega's Soft-ICE with trapping the
  42. VGA card's BIOS calls which modified the palettes. I made assembly routines
  43. (OS2PAL.ASM) and they worked under DOS and OS/2 on Video 7, Paradise, Compaq
  44. VGA and IBM PS/2 display aadapters with any 16 or 256 color resolution or PM
  45. driver.
  46.  
  47. When this routine is used, the following lines should be added to the .DEF 
  48. file of your program (or DLL):
  49.  
  50. SEGMENTS       PALETTE   IOPL
  51. EXPORTS
  52.                SETPAL_EGA   2
  53.                SETPAL_VGA   3
  54.  
  55. The values are entered as:
  56. void pascal far setpal_ega(USHORT color_number, USHORT palette_register);
  57. color_number is from 0 to 15 and palette register is from 0 to 63 with the 
  58. following bits:
  59.   1   - dark blue
  60.   2   - dark green
  61.   4   - dark red
  62.   8   - light blue
  63.  10   - light green
  64.  20   - light red
  65. void pascal far setpal_vga(USHORT color_number, ULONG  dac_register);
  66.  
  67. color_number is from 0 to 15 with 16 color PM drivers, dac_register is a long 
  68. consisted of three bytes RGB which each value from 0 to 63. E.g. yellow = 
  69. 0x00003F3F, white = 0x003F3F3F. Red and blue are reversed to PM !
  70. In setpal_vga() the color number is remapped to the palette register number 
  71. when a 16 color PM driver is used, in the same way as any VGA BIOS does. This 
  72. remapping should be disabled when a 256 color mode is used, so a color number 
  73. corresponds with a DAC register.
  74.  
  75. PAL2.ASM:
  76.  
  77. void pascal far remapallpalette(USHORT ncolors, COLOR far *table);
  78.  
  79. This routine is much better, is is VGA only, but the format of the color 
  80. table matches the PM COLOR union. The number ncolors must be either 16 or 256 
  81. dependant on the current PM driver DISPLAY.DLL. Moreover, the color intensity 
  82. of PM does not match with the real intensity. So is 'dark blue' 0x0000AA and 
  83. not 0x000080 as GpiQueryRealColors() says. PALETTE.C contains a conversion 
  84. routine between these the color intensity tables of PM and of 'real' VGA. It 
  85. if for both version 1.1 and 1.2. There are also two 'Gpi' routines in which 
  86. you can use as an extension to PM. You can make a DLL from this routine with 
  87.  
  88. make palette.mk
  89.  
  90. The data should be nonshared (see PALETTE.def).
  91.  
  92. You should add this line in the main window procedure of your program to 
  93. restore the default palette when your program gets inactive:
  94.  
  95.    /* current_pid is supposed to be the PID of the current program */
  96.  
  97.    case WM_FOCUSCHANGE:
  98.       WinQueryWindowProcess((HWND)mp1, (PPID)&pid, (PTID)&tid);
  99.       if (pid == current_pid)  /* do not change when another window of the */
  100.          break;                /* same process (e.g. a dialog box) is shown */
  101.  
  102.       if (SHORT1FROMMP(mp2))   /* application gains focus */
  103.          /* ..... set application color palette ..... */
  104.       else                     /* application loses focus */
  105.          /* ..... set system default palette ........ */
  106.       break;
  107. Klaas van Ditzhuyzen
  108. DATAD Telecom
  109. P.O.Box 371 3900 AJ Veenendaal Holland
  110. Tel +31 8385 33400
  111.  
  112. colleague of Martin Vermeer #839 on Magnum BBS : (805) 581-1275
  113.