home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / TEXTMODE.TXT < prev    next >
Text File  |  1996-08-05  |  5KB  |  155 lines

  1. Font Set Manipulation in Textmode.
  2.  
  3.  
  4.  
  5. 1. Introduction
  6. 2. Enable/Disable Font Manipulation
  7. 3. Secondary Font Set
  8. 4. BW Dithering
  9. 5. Finito
  10.  
  11.  
  12.  
  13. 1. Introduction
  14.  
  15. As many of you probably have noticed, Symantec uses a smooth mouse_arrow
  16. in textmode. The trick is font set manipulation. The phong_face in
  17. FAQSYS_about is also done with font set manipulation. How is it done?
  18.  
  19. Remember to be in textmode!
  20.  
  21.  
  22.  
  23.  
  24. 2. Enable/Disable Font Manipulation
  25.  
  26. Well, first you will have to enable font manipulation. This is done by
  27. writing some word values to some ports:
  28.  
  29.   port(0x03c4) = 0x0402;  Wait;
  30.   port(0x03c4) = 0x0704;  Wait;
  31.   port(0x03ce) = 0x0204;  Wait;
  32.   port(0x03ce) = 0x0005;  Wait;
  33.   port(0x03ce) = 0x0006;  Wait;
  34.  
  35. After each port_writing you have to wait some ticks. I think you have to wait
  36. 6 cycles or something, so this will work:
  37.  
  38.   for (i=0; i<3; ++i);
  39.  
  40. Now your videocard has enabled the font set to be manipulated. The font set
  41. has been copied to memory_address A000:0000. Each character (0 to 255) is
  42. located at a 32-byte block. So if you wanna find the offset to the char 'A',
  43. which has ASCII code 65, just:
  44.  
  45.   A_address = 32*65;
  46.  
  47. Only the first 16-byte block contains character-bitdata. As you know in
  48. 80x25x16 (mode 3) the font set is 8x16, this means each byte in the 16-byte
  49. block presents one scanline, which means 8 pixels. The letter 'A' has this
  50. bitdata: (or something like this (I am not a graphic_man)!)
  51.  
  52.  
  53.  128 32   8   2
  54.    64  16   4   1
  55. ╔════════════════╗
  56. ║                ║ = 00000000 = 0
  57. ║                ║ = 00000000 = 0
  58. ║                ║ = 00000000 = 0
  59. ║      ██        ║ = 00010000 = 16
  60. ║    ██  ██      ║ = 00101000 = 40
  61. ║  ██      ██    ║ = 01000100 = 68
  62. ║  ██      ██    ║ = 01000100 = 68
  63. ║██          ██  ║ = 10000010 = 130
  64. ║██          ██  ║ = 10000010 = 130
  65. ║██████████████  ║ = 11111110 = 254
  66. ║██          ██  ║ = 10000010 = 130
  67. ║██          ██  ║ = 10000010 = 130
  68. ║                ║ = 00000000 = 0
  69. ║                ║ = 00000000 = 0
  70. ║                ║ = 00000000 = 0
  71. ║                ║ = 00000000 = 0
  72. ╚════════════════╝              
  73.                                 
  74.                          ┌──────┘
  75.                    ┌─────┴─────┐
  76. Well, this is your 16-byte block for the beatiful letter 'A'. Just write it
  77. at offset (32*65). As you have finished manipulated chars, you will have to
  78. tell your videocard to save the font set and disable font manipulation.
  79. This is done almost the same way as enabling it. Some word values to some
  80. ports:
  81.  
  82.   port(0x03c4) = 0x0302;  Wait;
  83.   port(0x03c4) = 0x0304;  Wait;
  84.   port(0x03ce) = 0x0004;  Wait;
  85.   port(0x03ce) = 0x1005;  Wait;
  86.   port(0x03ce) = 0x0e06;  Wait;
  87.  
  88.  
  89. If you have studied the Symantec_mousearrow you probably noticed the
  90. arrow changs some chars by adding a 9th bit. Well, the answer is that you
  91. have to use 9-bits chars (e.g ═ ┘─ ┐), so you don't get the arrow ugly_looking
  92. with vertical-lines! (There is one pixel_space between the chars on screen,
  93. except for 9-bit chars. The 9th bit is simply a copy of the first bit, so
  94. that is why some chars looks ugly. I am not sure if you can choose which
  95. char to be 9-bit, but I haven't done any research either.
  96.  
  97.  
  98.  
  99. 3. Secondary Font Set
  100.  
  101. Another thing which is very interesting is to enable the secondary font-set,
  102. which means you don't have to care about all the chars you mess with, but
  103. there is one defect. As you enable the secondary font-set, you use one bit
  104. more, which means you will only get 0..7 background colors. If you like this
  105. and wanna enable 512-font set, do like this:
  106.  
  107.   AH = 0x11
  108.   AL = 0x03
  109.   BL = 0x12
  110.   INT 0x10
  111.  
  112.  
  113. BL selects the charactor sets VIA bit 3 in char attribute. BL must be loaded
  114. so the video_controller knows which block to use. Depending on wether bit 3
  115. of the charactor attribute is ON or OFF. The upper 4 bits selects a block
  116. number to use for the ON state of bit 3, the lower four bits selects the OFF
  117. state of bit 3.
  118.  
  119.  
  120.  
  121. 4. BW Dithering
  122.  
  123. If you are thinking of doing demo_effects in textmode with manipulated
  124. chars as the FAQSYS_vector, you will probably need a BW dither procedure.
  125. I read a Microsoft_doc once, and they said that pattern-dithering was
  126. very popular and classic. I tried it and it worked.
  127. Imagine you use 64 colors of shading in your virtual screenbuffer, and
  128. you wanna convert it to 2 colors, so it will look ok in textmode, you
  129. can replace each pixel with the pixel in the dither_pattern for that color.
  130.  
  131. First precalc 64 patterns, 16x16 resolution works fine.
  132. Pattern  0 is empty
  133. Pattern 32 is half filled (every other pixel)
  134. Pattern 63 is solid filled
  135.  
  136. So as you convert your virtual screenbuffer pixel by pixel, your dither_pixel
  137. is found by:
  138.  
  139.                               Which pattern
  140.                                    │   Y-Coordinate in pattern
  141.                                    │          │   X-Coordinate in pattern
  142.                                                        
  143.  
  144.   dither_pixel = dither_pattern[shadecolor][y and 15][x and 15]
  145.  
  146. I don't know if this is the correct way, but it works ok.
  147.  
  148.  
  149. 5. Finito
  150.  
  151. I think that was all. Not much, but ok if you didn't already knew this.
  152. Sorry, but my english could be much better.
  153.  
  154. - STEFF/Sorrox
  155.