Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
3.9 KiB

  1. GenFont:
  2. ; FUNCTION = make pattern completly
  3. ; INPUT : (DS=CS) CX = KS code, ES:DI = buffer pointer
  4. ; OUTPUT : (NC) ES:DI = buffer pointer
  5. ; PROTECT : none
  6. extrn Ks2ChAddr:word
  7. VowelTypeCnt = 3
  8. push bp
  9. push di
  10. mov ax,cx
  11. mov bp,di ; save buffer pointer
  12. test [CodeStat],Chab
  13. jnz @f
  14. call [Ks2ChAddr]
  15. jnc @f
  16. jmp MakeFontEnd
  17. @@:
  18. call ChkVowelType ; check vowel type
  19. add si,[PatGenAddr]
  20. mov di,bp
  21. mov dx,ax ; save CH code
  22. xor ax,ax
  23. mov cx,16
  24. rep stosw ; clear buffer
  25. ; DX = CH code, BP = buffer pointer, SI = type no.
  26. add si,offset Type1stTbl - offset GenFont
  27. push dx
  28. mov di,[HanPatternPtr]
  29. add di,FontStruc1st
  30. and dx,0111110000000000b
  31. mov cl,7
  32. rol dx,cl
  33. call MakePattern
  34. pop dx
  35. jc MakeFontEnd
  36. @@:
  37. add si,offset Type2ndTbl - offset Type1stTbl
  38. push dx
  39. mov di,[HanPatternPtr]
  40. add di,FontStruc2ndV
  41. push si
  42. mov si,dx
  43. mov cl,5
  44. shr si,cl
  45. and si,0000000000011111b
  46. add si,offset VowelType - offset GenFont
  47. add si,[PatGenAddr]
  48. mov al,[si]
  49. dec al
  50. mov ah,4*VowelTypeCnt
  51. mul ah
  52. pop si
  53. add di,ax
  54. and dx,0000001111100000b
  55. mov cl,4
  56. shr dx,cl
  57. add dx,32*2
  58. call MakePattern
  59. pop dx
  60. jc MakeFontEnd
  61. @@:
  62. add si,offset Type3rdTbl - offset Type2ndTbl
  63. mov di,[HanPatternPtr]
  64. add di,FontStruc3rd
  65. and dx,0000000000011111b
  66. shl dx,1
  67. add dx,32*2*2
  68. call MakePattern
  69. MakeFontEnd:
  70. pop di
  71. pop bp
  72. ret
  73. ChkVowelType:
  74. ; FUNCTION = get vowel type bits(4)
  75. ; INPUT : (DS=CS)AX = CH code
  76. ; OUTPUT : (CC) SI = vowel type code(4 bits)
  77. ; DESTORY : CX, DX
  78. mov si,ax
  79. mov cl,5
  80. shr si,cl
  81. and si,0000000000011111b
  82. add si,offset VowelType - offset GenFont
  83. add si,[PatGenAddr]
  84. mov cl,[si]
  85. shl cl,1
  86. shl cl,1 ; 0000xx00b
  87. mov dx,ax
  88. and dx,0111110000011111b
  89. cmp dh,00000100b ; 1st fill code ?
  90. jz @f ; jump if so
  91. or cl,00000001b ; 0000xxx1b
  92. @@:
  93. cmp dl,00000001b ; last fill code ?
  94. jz @f ; jump if so
  95. or cl,00000010b ; 0000xx1xb
  96. @@:
  97. xor ch,ch
  98. mov si,cx
  99. ret
  100. MakePattern:
  101. ; FUNCTION = make pattern
  102. ; INPUT : (DS=CS) BP = buffer pointer, DX = input code
  103. ; DI = font struc pointer, CL = real type no.
  104. ; OUTPUT : none
  105. ; DESTORY : AX, BX, CX, DI
  106. push si
  107. mov cl,[si] ; get type no.
  108. mov si,dx
  109. add si,[HanPatternPtr]
  110. mov si,[si]
  111. or si,si
  112. jz MakePatternFill
  113. or si,si
  114. js MakePatternErr ; jump if MSB = 1
  115. or cl,cl
  116. js MakePatternFill ; jump if MSB = 1
  117. xor ch,ch
  118. xor bx,bx
  119. @@:
  120. jcxz @f
  121. mov ax,[di+2]
  122. mul ah
  123. add bx,ax ; BX = byte size
  124. add di,4
  125. loop @b
  126. @@:
  127. add si,[HanPatternPtr]
  128. add si,bx
  129. mov bx,di
  130. ; calc target address
  131. mov di,bp
  132. mov ax,[bx] ; get (X, Y)
  133. mov cl,al
  134. mov al,ah
  135. xor ah,ah
  136. shl ax,1
  137. add di,ax
  138. xor ch,ch
  139. add di,cx
  140. ; calc repeat counter
  141. mov dx,[bx+2]
  142. mov bl,dh
  143. mov bh,dl
  144. mov dl,2 ; 16 dot
  145. sub dl,bh
  146. xor dh,dh ; AX = blank byte
  147. xor ch,ch
  148. MakeFontLoop:
  149. mov cl,bh ; BH = repeat counter
  150. @@:
  151. lodsb
  152. or es:[di],al
  153. inc di
  154. loop @b
  155. add di,dx
  156. dec bl
  157. jnz MakeFontLoop
  158. MakePatternFill:
  159. pop si
  160. ret
  161. MakePatternErr:
  162. pop si
  163. stc
  164. ret
  165. VowelType label byte
  166. db 0,0,0,1,1,1,1,1,0,0,1,1,1,2,3,3
  167. db 0,0,3,2,2,3,3,3,0,0,2,2,3,1,0,0
  168. Type1stTbl label byte
  169. db -1, 0,-1, 4,-1, 1,-1, 2,-1, 3,-1, 4,-1, 6,-1, 5
  170. Type2ndTbl label byte
  171. db -1,-1,-1,-1, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2
  172. Type3rdTbl label byte
  173. db -1,-1, 0, 1,-1,-1, 0, 1,-1,-1, 0, 1,-1,-1, 0, 1
  174. FontStruc STRUC
  175. Char1st dw 32 dup(?) ; 1st code word table
  176. Char2nd dw 32 dup(?) ; 2nd code word table
  177. Char3rd dw 32 dup(?) ; 3rd code word table
  178. FontStruc1st db 4*7 dup(?) ; 1st code struc table
  179. FontStruc2ndV db 4*3 dup(?) ; 2nd V-vowel code struc table
  180. FontStruc2ndH db 4*3 dup(?) ; 2nd H-vowel code struc table
  181. FontStruc2ndHV db 4*3 dup(?) ; 2nd HV-vowel code struc table
  182. FontStruc3rd db 4*2 dup(?) ; 3rd code struc table
  183. RealFont db ? ; font image area
  184. FontStruc ENDS
  185. CharTbl label word
  186. INCLUDE HAN.PAT
  187. GenFontLng = $-GenFont
  188.