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.

1394 lines
48 KiB

  1. ;===============================================================================
  2. ;
  3. ; $Workfile: TEXT.ASM $
  4. ;
  5. ; Contents:
  6. ; This file contains the assembly code for the text output routine.
  7. ;
  8. ; Copyright (c) 1996, Cirrus Logic, Inc.
  9. ;
  10. ; $Log: //uinac/log/log/laguna/nt35/displays/cl546x/i386/TEXT.ASM $
  11. ;
  12. ; Rev 1.23 Jun 22 1998 11:07:36 frido
  13. ; PDR#11546. Fixed save/restore in clipping BugLoop and also
  14. ; the register increments in DrawLoop.
  15. ;
  16. ; Rev 1.22 Mar 04 1998 15:47:14 frido
  17. ; Added more shadowing.
  18. ;
  19. ; Rev 1.21 Jan 21 1998 17:12:36 frido
  20. ; Added SWAT6 switches to stripe the opaque rectangles.
  21. ;
  22. ; Rev 1.20 Jan 20 1998 11:45:12 frido
  23. ; Added shadowing for DRAWBLTDEF and BGCOLOR registers.
  24. ;
  25. ; Rev 1.19 Dec 11 1997 16:02:46 frido
  26. ; Oops...
  27. ;
  28. ; Rev 1.18 Dec 11 1997 15:41:18 frido
  29. ; PDR#10875: There was a very weird instruction in the DrawGlyph
  30. ; routine with clipped non-cacheable glyphs.
  31. ;
  32. ; Rev 1.17 Nov 03 1997 17:41:58 frido
  33. ; Added REQUIRE macros.
  34. ;
  35. ; Rev 1.16 08 Aug 1997 17:22:32 FRIDO
  36. ; Added SWAT7 switches for 8-bpp hardware bug.
  37. ;
  38. ; Rev 1.15 29 Apr 1997 16:29:40 noelv
  39. ; Merged in new SWAT code.
  40. ; SWAT:
  41. ; SWAT: Rev 1.3 24 Apr 1997 10:45:54 frido
  42. ; SWAT: NT140b09 merge.
  43. ; SWAT:
  44. ; SWAT: Rev 1.2 19 Apr 1997 16:31:54 frido
  45. ; SWAT: Added automatic include file dependencies for BUILD.EXE.
  46. ;
  47. ; Rev 1.14 08 Apr 1997 11:48:24 einkauf
  48. ;
  49. ; add call to SYNC_W_3D for MCD coordination
  50. ;
  51. ; Rev 1.13 21 Mar 1997 10:10:20 noelv
  52. ; Synced PDEV between C code and ASM code.
  53. ; Added macro to log QFREE data.
  54. ; Consolidated do_flag and sw_test_flag into a single pointer_switch flag.
  55. ;
  56. ; Rev 1.12 07 Mar 1997 09:41:02 SueS
  57. ; Added NULL_TEXTOUT flag to assembly code. Changed order of include files.
  58. ;
  59. ; Rev 1.11 05 Mar 1997 10:37:32 noelv
  60. ;
  61. ; Marked where to put tests for QFREE
  62. ;
  63. ; Rev 1.10 04 Feb 1997 12:19:28 SueS
  64. ; Added support for hardware clipping for the 5465.
  65. ;
  66. ; Rev 1.9 20 Aug 1996 11:28:52 noelv
  67. ; Bugfix release from Frido 8-19-96
  68. ;
  69. ; Rev 1.0 14 Aug 1996 17:14:38 frido
  70. ; Initial revision.
  71. ;
  72. ; Rev 1.8 25 Jul 1996 15:49:52 bennyn
  73. ; Modified to support DirectDraw
  74. ;
  75. ; Rev 1.7 03 May 1996 15:24:24 noelv
  76. ;
  77. ; Added switch to turn font caching on and off.
  78. ;
  79. ; Rev 1.6 01 May 1996 11:06:46 bennyn
  80. ;
  81. ; Modified for NT 4.0
  82. ;
  83. ; Rev 1.5 04 Apr 1996 13:22:18 noelv
  84. ; Frido version 26
  85. ;
  86. ; Rev 1.14 28 Mar 1996 23:38:52 frido
  87. ; Fixed drawing of partially left-clipped glyphs.
  88. ;
  89. ; Rev 1.13 04 Mar 1996 20:23:50 frido
  90. ; Cached grCONTROL register.
  91. ;
  92. ; Rev 1.12 29 Feb 1996 20:21:32 frido
  93. ; Fixed some pointer updates.
  94. ;
  95. ; Rev 1.11 28 Feb 1996 22:40:22 frido
  96. ; Added Optimize.h.
  97. ;
  98. ; Rev 1.10 27 Feb 1996 23:52:40 frido
  99. ; Removed bug in DrawGlyph with non clipped characters.
  100. ;
  101. ; Rev 1.9 27 Feb 1996 16:39:54 frido
  102. ; Added device bitmap store/restore.
  103. ;
  104. ; Rev 1.8 24 Feb 1996 01:22:58 frido
  105. ; Added device bitmaps.
  106. ;
  107. ; Rev 1.7 19 Feb 1996 06:24:28 frido
  108. ; Removed extraneous debugging code.
  109. ; Added comments.
  110. ;
  111. ; Rev 1.6 17 Feb 1996 21:46:44 frido
  112. ; Changed FIFO_CHECK into broken_FIFO.
  113. ;
  114. ; Rev 1.5 08 Feb 1996 00:03:54 frido
  115. ; Added i386\ to include files.
  116. ;
  117. ; Rev 1.4 06 Feb 1996 16:13:16 frido
  118. ; Added check for invalid rectangle during clippped opaquing.
  119. ;
  120. ; Rev 1.3 03 Feb 1996 12:17:28 frido
  121. ; Added text clipping.
  122. ;
  123. ; Rev 1.2 25 Jan 1996 22:14:10 frido
  124. ; Removed extraneous push/pop instructions.
  125. ;
  126. ; Rev 1.1 25 Jan 1996 12:42:38 frido
  127. ; Added reinitialization of font cache after mode switch.
  128. ;
  129. ; Rev 1.0 24 Jan 1996 23:13:44 frido
  130. ; Initial release.
  131. ;
  132. ;===============================================================================
  133. .386
  134. .MODEL FLAT, STDCALL
  135. .NOLIST
  136. INCLUDE i386\Macros.inc
  137. INCLUDE i386\WinNT.inc
  138. INCLUDE i386\Font.inc
  139. INCLUDE Optimize.h
  140. INCLUDE i386\Laguna.inc
  141. INCLUDE Swat.h
  142. COMMENT ! ;automatic include file dependencies for BUILD.EXE
  143. #include "i386\Macros.inc"
  144. #include "i386\WinNT.inc"
  145. #include "i386\Font.inc"
  146. #include "Optimize.h"
  147. #include "i386\Laguna.inc"
  148. #include "SWAT.h"
  149. !
  150. .LIST
  151. IF USE_ASM
  152. .DATA
  153. IF POINTER_SWITCH_ENABLED
  154. EXTERN pointer_switch: DWORD
  155. ENDIF
  156. IF LOG_QFREE
  157. EXTERN QfreeData: DWORD
  158. ENDIF
  159. .CODE
  160. ;
  161. ; Function prototypes.
  162. ;
  163. AddToFontCacheChain PROTO PROC,
  164. ppdev :DWORD,
  165. pfo :DWORD,
  166. pfc :DWORD
  167. AllocGlyph PROTO PROC,
  168. pfc :DWORD,
  169. pgb :DWORD,
  170. pgc :DWORD
  171. i386DrvTextOut PROTO PROC,
  172. pso :DWORD,
  173. pstro :DWORD,
  174. pfo :DWORD,
  175. pco :DWORD,
  176. prclExtra :DWORD,
  177. prclOpaque :DWORD,
  178. pboFore :DWORD,
  179. pboOpaque :DWORD,
  180. pptlBrush :DWORD,
  181. mix :DWORD
  182. EngTextOut PROTO PROC,
  183. pso :DWORD,
  184. pstro :DWORD,
  185. pfo :DWORD,
  186. pco :DWORD,
  187. prclExtra :DWORD,
  188. prclOpaque :DWORD,
  189. pboFore :DWORD,
  190. pboOpaque :DWORD,
  191. pptlBrush :DWORD,
  192. mix :DWORD
  193. DrvDestroyFont PROTO PROC,
  194. pfo :DWORD
  195. bCreateScreenFromDib PROTO PROC,
  196. ppdev :DWORD,
  197. pdsurf :DWORD
  198. StripePatBlt PROTO PROC,
  199. ppdev :DWORD,
  200. x :DWORD,
  201. y :DWORD,
  202. nWidth :DWORD,
  203. nHeight :DWORD
  204. ifdef WINNT_VER40
  205. Sync_w_3d_proc PROTO PROC,
  206. ppdev :PTR PDEV
  207. endif
  208. ;
  209. ; Stack frame for DrvTextOut.
  210. ;
  211. espPTR = 0
  212. frmPTR = 0
  213. pso_ TEXTEQU <DWORD PTR [esp + 4 + espPTR]>
  214. pstro_ TEXTEQU <DWORD PTR [esp + 8 + espPTR]>
  215. pfo_ TEXTEQU <DWORD PTR [esp + 12 + espPTR]>
  216. pco_ TEXTEQU <DWORD PTR [esp + 16 + espPTR]>
  217. prclExtra_ TEXTEQU <DWORD PTR [esp + 20 + espPTR]>
  218. prclOpaque_ TEXTEQU <DWORD PTR [esp + 24 + espPTR]>
  219. pboFore_ TEXTEQU <DWORD PTR [esp + 28 + espPTR]>
  220. pboOpaque_ TEXTEQU <DWORD PTR [esp + 32 + espPTR]>
  221. pptlBrush_ TEXTEQU <DWORD PTR [esp + 36 + espPTR]>
  222. mix_ TEXTEQU <DWORD PTR [esp + 40 + espPTR]>
  223. OPTION PROLOGUE:None
  224. OPTION EPILOGUE:None
  225. DrvTextOut PROC PUBLIC,
  226. pso :DWORD,
  227. pstro :DWORD,
  228. pfo :DWORD,
  229. pco :DWORD,
  230. prclExtra :DWORD,
  231. prclOpaque :DWORD,
  232. pboFore :DWORD,
  233. pboOpaque :DWORD,
  234. pptlBrush :DWORD,
  235. mix :DWORD
  236. IF NULL_TEXTOUT
  237. cmp pointer_switch, 0 ; Has the cursor been moved to (0,0)?
  238. je NotNull ; No - continue on
  239. mov eax, 1 ; Make GDI think we succeeded
  240. ret 40 ; Return and release stack frame
  241. NotNull:
  242. ENDIF
  243. push_ edi
  244. mov edi, [pfo_] ;EDI holds pointer to font
  245. ASSUME edi:PTR FONTOBJ
  246. mov ecx, [pso_] ;ECX holds pointer to destination
  247. ASSUME ecx:PTR SURFOBJ
  248. push_ esi
  249. push_ ebp
  250. push_ ebx
  251. save_ 1 ;save current stack state
  252. mov edx, [pstro_] ;EDX holds pointer to string
  253. ASSUME edx:PTR STROBJ
  254. mov ebx, [ecx].dhsurf ;get the pointer to the device bitmap
  255. ASSUME ebx:PTR DSURF
  256. mov esi, [edi].pvConsumer ;ESI holds pointer to font cache
  257. ASSUME esi:PTR FONTCACHE
  258. cmp [ecx].iType, STYPE_DEVBITMAP
  259. ;are we drawing in a device bitmap?
  260. mov ebp, [ecx].dhpdev ;EBP holds pointer to device
  261. ASSUME ebp:PTR PDEV
  262. jne @F ;no
  263. ifdef WINNT_VER40
  264. ;SYNC_W_3D macro equivalent
  265. cmp [ebp].NumMCDContexts, 0 ; is MCD alive?
  266. jle Sync_end ; no
  267. push ecx ; save
  268. push edx ; save
  269. push ebp ; input to Sync_w_3d_proc
  270. call Sync_w_3d_proc
  271. pop edx ; restore
  272. pop ecx ; restore
  273. Sync_end:
  274. endif
  275. mov ebx, [ebx].pso ;get the handle to the DIB
  276. or ebx, ebx ;is the device bitmap a DIB?
  277. jz @F ;no
  278. INVOKE bCreateScreenFromDib, ;copy the DIB to off-screen
  279. ebp,
  280. ebx
  281. or eax, eax
  282. jz Simulate ;failure
  283. @@: cmp [ebp].UseFontCache, 0 ;Is font caching enabled?
  284. je FontNotCached ;no, use C code.
  285. or esi, esi ;is font cache allocated?
  286. jz NewFont ;no, new font
  287. cmp esi, -1 ;is font uncacheable?
  288. je FontNotCached ;yes
  289. cmp [esi].ppdev, ebp ;font cached in current device?
  290. mov eax, [ebp].ulFontCount
  291. jne FontNotCached ;no
  292. cmp [esi].ulFontCount, eax ;device count still matches?
  293. jne DestroyFont ;no, recache font
  294. ;
  295. ; We have a font that is still cached.
  296. ;
  297. FontCached:
  298. mov ebx, [pco_] ;EBX holds pointer to clip object
  299. ASSUME ebx:PTR CLIPOBJ
  300. mov eax, [pboFore_] ;EAX has foreground brush
  301. ASSUME eax:PTR BRUSHOBJ
  302. mov edx, [pboOpaque_] ;EDX has background brush
  303. ASSUME edx:PTR BRUSHOBJ
  304. or ebx, ebx ;clip object present?
  305. jz @F ;no
  306. cmp [ebx].iDComplexity, DC_TRIVIAL
  307. ;trivial clipping?
  308. jne CheckClipping ;no, check for clipping
  309. @@: cmp [ebp].iBytesPerPixel, 2
  310. mov ebx, ebp ;store pointer to PDEV structure
  311. mov ebp, [ebp].pLgREGS_real ;EBP holds pointer to Laguna registers
  312. ASSUME ebp:NOTHING
  313. mov eax, [eax].iSolidColor ;get foreground color
  314. ASSUME eax:NOTHING
  315. mov edx, [edx].iSolidColor ;get background color
  316. ASSUME edx:NOTHING
  317. ja @F ;no color translation needed
  318. je Xlate16 ;16-bpp
  319. mov ah, al ;expand 8-bpp into 16-bit
  320. mov dh, dl
  321. Xlate16:
  322. mov ecx, eax ;expand 16-bpp into 32-bit
  323. shl eax, 16
  324. mov esi, edx
  325. shl edx, 16
  326. or eax, ecx
  327. or edx, esi
  328. @@: ASSUME ebx:PTR PDEV
  329. REQUIRE 4, ebx
  330. cmp [ebx].shadowFGCOLOR, eax
  331. je @F
  332. mov [ebp + grOP_opFGCOLOR], eax
  333. mov [ebx].shadowFGCOLOR, eax;store foreground color in Laguna
  334. @@: mov eax, [pso_] ;EAX holds pointer to destination
  335. ASSUME eax:PTR SURFOBJ
  336. cmp [ebx].shadowBGCOLOR, edx
  337. je @F
  338. mov [ebp + grOP_opBGCOLOR], edx
  339. mov [ebx].shadowBGCOLOR, edx;store background color in Laguna
  340. @@: xor edx, edx ;zero x/y offset
  341. cmp [eax].iType, STYPE_DEVBITMAP
  342. mov eax, [eax].dhsurf ;get pointer to device bitmap
  343. ASSUME eax:PTR DSURF
  344. jne @F ;target is not a device bitmap
  345. mov edx, [eax].packedXY ;get packed x/y offset of device bitmap
  346. @@: mov eax, [prclOpaque_] ;EAX holds opaquing rectangle
  347. ASSUME eax:PTR RECTL
  348. mov [mix_], edx ;store x/y offset into mix variable
  349. test eax, eax ;opaquing rectangle present?
  350. jz SkipOpaque ;no
  351. ASSUME ebx:PTR PDEV
  352. REQUIRE 7, ebx
  353. cmp [ebx].shadowDRAWBLTDEF, SOLID_COLOR_FILL
  354. je @F
  355. mov DWORD PTR [ebp + grDRAWBLTDEF], SOLID_COLOR_FILL
  356. mov [ebx].shadowDRAWBLTDEF, SOLID_COLOR_FILL
  357. @@: ;use solid background fill
  358. mov edi, [eax].left ;get rectangle coordinates
  359. mov ecx, [eax].top
  360. mov edx, [eax].right
  361. mov eax, [eax].bottom
  362. sub edx, edi ;convert to size
  363. sub eax, ecx
  364. IF SWAT6
  365. push_ ebx
  366. mov ebx, [mix_]
  367. and ebx, 0000FFFFh
  368. add edi, ebx
  369. mov ebx, [mix_]
  370. shr ebx, 16
  371. add ecx, ebx
  372. pop_ ebx
  373. INVOKE StripePatBlt, ebx, edi, ecx, edx, eax
  374. ELSE
  375. shl ecx, 16 ;pack x/y
  376. add edi, [mix_] ;add x/y offset to left
  377. shl eax, 16
  378. add ecx, edi
  379. or eax, edx
  380. mov [ebp + grOP0_opRDRAM], ecx
  381. ;draw rectangle
  382. mov [ebp + grBLTEXT_EX], eax
  383. ENDIF
  384. SkipOpaque:
  385. mov ax, [ebp + grCONTROL]
  386. mov edi, [pfo_] ;EDI holds pointer to font
  387. ASSUME edi:PTR FONTOBJ
  388. or eax, SWIZ_CNTL ;enable bit mirroring
  389. cmp [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  390. je @F
  391. mov DWORD PTR [ebp + grDRAWBLTDEF], CACHE_EXPAND_XPAR
  392. mov [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  393. @@: ;expand characters from cache
  394. mov [ebp + grCONTROL], ax
  395. mov edx, ebx ;store pointer to PDEV structure
  396. mov ebx, [pstro_] ;EBX holds pointer to string
  397. ASSUME ebx:PTR STROBJ
  398. mov edi, [edi].pvConsumer ;EDI holds pointer to font cache
  399. ASSUME edi:PTR FONTCACHE
  400. ;
  401. ; We are now ready to start the main font cache loop. We first determine if we
  402. ; need to enumerate the GLYPHPOS arrays or not. Then we start the main loop,
  403. ; which is a very short simple loop. For each glyph that falls in the caching
  404. ; range, we check if the glyph is cached. If so, we just copy the glyph from
  405. ; off-screen memory. If the glyph is not cached, we check if it is small enough
  406. ; to fit in a tile and if so, we cache it off-screen and than copy itto its
  407. ; destination. If the glyph is too large, we draw it directly on screen.
  408. ;
  409. enter_ 16 ;create stack frame
  410. bMoreGlyphs_ TEXTEQU <DWORD PTR [esp + 0 + frmPTR]>
  411. ulCharInc_ TEXTEQU <DWORD PTR [esp + 4 + frmPTR]>
  412. dwControl_ TEXTEQU <DWORD PTR [esp + 8 + frmPTR]>
  413. pdev_ TEXTEQU <DWORD PTR [esp + 12 + frmPTR]>
  414. save_ 2 ;store state of stack
  415. mov [pdev_], edx
  416. mov [dwControl_], eax
  417. mov eax, [ebx].ulCharInc ;copy ulCharInc from string object
  418. cmp [ebx].pgp, 0
  419. mov [ulCharInc_], eax
  420. je Enumerate ;there is more than one array
  421. mov ecx, [ebx].cGlyphs ;get number of glyphs to draw
  422. mov ebx, [ebx].pgp ;get pointer to glyph position array
  423. ASSUME ebx:PTR GLYPHPOS
  424. mov [bMoreGlyphs_], 0 ;no more glyphs to enumerate
  425. MainLoop:
  426. or ecx, ecx ;any glyphs to draw?
  427. je SkipLoop ;no
  428. mov eax, [ebx].ptl.x ;get coordinates of first glyph
  429. mov edx, [ebx].ptl.y
  430. GlyphLoop:
  431. push_ ecx
  432. mov ecx, [ebx].hg ;get the glyph handle
  433. cmp [ulCharInc_], 0 ;fixed font?
  434. jne @F ;no
  435. mov eax, [ebx].ptl.x ;get coordinates for glyph
  436. mov edx, [ebx].ptl.y
  437. @@: shl ecx, 4 ;build index into font cache array
  438. cmp ecx, MAX_GLYPHS * 16 ;glyph out of range?
  439. jnl DrawGlyph ;yes, draw it directly
  440. save_ 9
  441. mov esi, [edi + ecx*1].aGlyphs.xyPos
  442. ;get off-screen location of glyph
  443. lea ecx, [edi + ecx*1].aGlyphs
  444. ;load address of cache slot
  445. ASSUME ecx:PTR GLYPHCACHE
  446. or esi, esi ;is the glyph already cached?
  447. jnz @F ;yes
  448. mov esi, [ebx].pgdf ;cache the glyph
  449. ASSUME esi:PTR GLYPHDEF
  450. push eax
  451. push edx
  452. push ecx
  453. INVOKE AllocGlyph,
  454. edi,
  455. [esi].pgb,
  456. ecx
  457. pop ecx
  458. pop edx
  459. pop eax
  460. mov esi, [ecx].xyPos ;get off-screen location of glyph
  461. @@: cmp [ecx].cSize, 0 ;is this an empty glyph?
  462. jl DrawGlyph ;no, in fact it is non-cacheable
  463. jz Increment ;yes, skip it
  464. push_ edx
  465. push_ eax
  466. add edx, [ecx].ptlOrigin.y ;add origin of glyph to coordinates
  467. add eax, [ecx].ptlOrigin.x
  468. shl edx, 16 ;pack coordinates
  469. or edx, eax
  470. mov eax, [pdev_]
  471. ASSUME eax:PTR PDEV
  472. REQUIRE 7, eax
  473. mov [ebp + grOP2_opMRDRAM], esi
  474. ;copy the glyph from off-screen memory
  475. mov esi, [mix_] ;get x/y offset
  476. mov eax, [ecx].cSize
  477. add edx, esi ;add x/y offset
  478. mov [ebp + grOP0_opRDRAM], edx
  479. mov [ebp + grBLTEXT_EX], eax
  480. pop_ eax
  481. pop_ edx
  482. Increment:
  483. add eax, [ulCharInc_] ;add the x-increment
  484. pop_ ecx
  485. add ebx, SIZEOF GLYPHPOS ;next glyph
  486. dec ecx
  487. jnz GlyphLoop
  488. SkipLoop:
  489. cmp [bMoreGlyphs_], 0 ;more arrays to draw?
  490. jne Enumerate ;yes
  491. mov ecx, [dwControl_]
  492. leave_ 16 ;remove stack frame
  493. and ecx, NOT SWIZ_CNTL ;reset bit mirroring
  494. mov eax, 1 ;return TRUE
  495. mov [ebp + grCONTROL], cx
  496. pop_ ebx
  497. pop_ ebp
  498. pop_ esi
  499. pop_ edi
  500. ret 40
  501. ;
  502. ; Draw the glyph directly to screen.
  503. ;
  504. DrawGlyph:
  505. load_ 9
  506. mov esi, [ebx].pgdf ;ESI holds pointer to GLYPHDEF
  507. ASSUME esi:PTR GLYPHDEF
  508. push_ eax
  509. push_ edx
  510. mov esi, [esi].pgb ;ESI holds pointer to GLYPHBITS
  511. ASSUME esi:PTR GLYPHBITS
  512. push_ edi
  513. push_ ebx
  514. mov ebx, [pdev_]
  515. ASSUME ebx:PTR PDEV
  516. mov ecx, [esi].sizlBitmap._cy
  517. ;get height of glyph
  518. add edx, [esi].ptlOrigin.y ;add y-origin to coordinate
  519. shl ecx, 16
  520. jz SkipDraw ;if zero, skip
  521. shl edx, 16
  522. add eax, [esi].ptlOrigin.x ;add x-origin to coordinate
  523. mov edi, [esi].sizlBitmap._cx
  524. ;get width of glyph
  525. or edx, eax
  526. or ecx, edi
  527. add edx, [mix_] ;add x/y offset
  528. lea esi, [esi].aj ;ESI points to bits
  529. ASSUME esi:NOTHING
  530. IF SWAT7
  531. add edi, 7 ;convert width into byte delta
  532. REQUIRE 9, ebx
  533. cmp [ebx].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR
  534. je @F
  535. mov DWORD PTR [ebp + grDRAWBLTDEF], TEXT_EXPAND_XPAR
  536. mov [ebx].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR
  537. @@: shr edi, 3
  538. mov DWORD PTR [ebp + grOP2_opMRDRAM], 0
  539. cmp cx, 64 ;bug when doing 64 < width < 128
  540. jbe SkipBug
  541. cmp cx, 128
  542. jae SkipBug
  543. push ecx ;save registers
  544. push edx
  545. push esi
  546. mov cx, 64 ;1st passs, 64 pixels
  547. mov [ebp + grOP0_opRDRAM], edx
  548. mov [ebp + grBLTEXT_EX], ecx
  549. shr ecx, 16 ;get height into ECX
  550. @@: REQUIRE 2, ebx
  551. mov eax, [esi][0] ;transfer 64 pixels
  552. mov edx, [esi][4]
  553. mov [ebp + grHOSTDATA][0], eax
  554. mov [ebp + grHOSTDATA][4], edx
  555. add esi, edi ;next glyph line
  556. dec ecx
  557. jnz @B
  558. pop esi
  559. pop edx
  560. add esi, 64 / 8 ;8 bytes already done
  561. pop ecx
  562. add edx, 64 ;offset to next 64 pixels
  563. sub ecx, 64
  564. SkipBug:
  565. REQUIRE 5, ebx
  566. mov [ebp + grOP0_opRDRAM], edx
  567. mov edx, ecx ;get number of pixels into EDX
  568. mov [ebp + grBLTEXT_EX], ecx
  569. and edx, 0000FFFFh
  570. shr ecx, 16 ;get height back
  571. mov ebx, [pdev_]
  572. ASSUME ebx:PTR PDEV
  573. cmp edx, 8 ;test width
  574. jbe Draw1Byte ;glyph located in 1 byte
  575. cmp edx, 16
  576. jbe Draw2Bytes ;glyph located in 2 bytes
  577. cmp edx, 24
  578. jbe Draw3Bytes ;glyph located in 3 bytes
  579. cmp edx, 32
  580. jbe Draw4Bytes ;glyph located in 4 bytes
  581. DrawLoop:
  582. push edx ;store pixel count
  583. push esi ;store current byte offset
  584. @@: mov eax, [esi] ;get 4 bytes
  585. add esi, 4
  586. REQUIRE 1, ebx
  587. mov [ebp + grHOSTDATA], eax ;draw them
  588. sub edx, 32 ;32 pixels done
  589. jg @B ;still more bytes to copy
  590. pop esi ;restore byte offset
  591. pop edx ;restore pixel count
  592. add esi, edi ;next glyph row
  593. dec ecx
  594. jnz DrawLoop
  595. jmp SkipDraw
  596. Draw1Byte:
  597. mov al, [esi] ;get byte from glyph
  598. add esi, edi
  599. REQUIRE 1, ebx
  600. mov [ebp + grHOSTDATA], eax ;draw it
  601. dec ecx ;next glyph row
  602. jnz Draw1Byte
  603. jmp SkipDraw
  604. Draw2Bytes:
  605. mov ax, [esi] ;get 2 bytes from glyph
  606. add esi, edi
  607. REQUIRE 1, ebx
  608. mov [ebp + grHOSTDATA], eax ;draw them
  609. dec ecx ;next glyph row
  610. jnz Draw2Bytes
  611. jmp SkipDraw
  612. Draw4Bytes:
  613. mov eax, [esi] ;get 4 bytes from glyph
  614. add esi, edi
  615. REQUIRE 1, ebx
  616. mov [ebp + grHOSTDATA], eax ;draw them
  617. dec ecx ;next glyph row
  618. jnz Draw4Bytes
  619. jmp SkipDraw
  620. Draw3Bytes:
  621. mov al, [esi + 2] ;get 3 bytes from glyph
  622. shl eax, 16
  623. mov ax, [esi + 0]
  624. add esi, edi
  625. REQUIRE 1, ebx
  626. mov [ebp + grHOSTDATA], eax ;draw them
  627. dec ecx ;next glyph row
  628. jnz Draw3Bytes
  629. ELSE
  630. REQUIRE 7, ebx
  631. cmp [ebx].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR
  632. je @F
  633. mov DWORD PTR [ebp + grDRAWBLTDEF], TEXT_EXPAND_XPAR
  634. mov [ebx].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR
  635. @@: ;expand glyph on-screen
  636. mov [ebp + grOP0_opRDRAM], edx
  637. mov DWORD PTR [ebp + grOP2_opMRDRAM], 0
  638. mov [ebp + grBLTEXT_EX], ecx
  639. shr ecx, 16 ;get height back
  640. cmp edi, 8 ;test width
  641. jbe Draw1Byte ;glyph located in 1 byte
  642. cmp edi, 16
  643. jbe Draw2Bytes ;glyph located in 2 bytes
  644. cmp edi, 24
  645. jbe Draw3Bytes ;glyph located in 3 bytes
  646. cmp edi, 32
  647. jbe Draw4Bytes ;glyph located in 4 bytes
  648. add edi, 7 ;byte adjust glyph width
  649. shr edi, 3
  650. DrawLoop:
  651. mov edx, edi ;get width
  652. @@: mov eax, [esi] ;get 4 bytes
  653. add esi, 4
  654. REQUIRE 1, ebx
  655. mov [ebp + grHOSTDATA], eax ;draw them
  656. sub edx, 4 ;4 bytes done
  657. jg @B ;still more bytes to copy
  658. add esi, edx ;next glyph row
  659. dec ecx
  660. jnz DrawLoop
  661. jmp SkipDraw
  662. Draw1Byte:
  663. @@: mov al, [esi] ;get byte from glyph
  664. inc esi
  665. REQUIRE 1, ebx
  666. mov [ebp + grHOSTDATA], eax ;draw it
  667. dec ecx ;next glyph row
  668. jnz @B
  669. jmp SkipDraw
  670. Draw2Bytes:
  671. @@: mov ax, [esi] ;get 2 bytes from glyph
  672. add esi, 2
  673. REQUIRE 1, ebx
  674. mov [ebp + grHOSTDATA], eax ;draw them
  675. dec ecx ;next glyph row
  676. jnz @B
  677. jmp SkipDraw
  678. Draw4Bytes:
  679. @@: mov eax, [esi] ;get 4 bytes from glyph
  680. add esi, 4
  681. REQUIRE 1, ebx
  682. mov [ebp + grHOSTDATA], eax ;draw them
  683. dec ecx ;next glyph row
  684. jnz @B
  685. jmp SkipDraw
  686. Draw3Bytes:
  687. @@: mov eax, [esi] ;eax = 3210
  688. add esi, 4
  689. REQUIRE 4, ebx
  690. mov [ebp + grHOSTDATA], eax ;store 210
  691. dec ecx
  692. jz SkipDraw
  693. mov edx, [esi] ;edx = 7654
  694. add esi, 4
  695. shrd eax, edx, 24 ;eax = 6543
  696. dec ecx
  697. mov [ebp + grHOSTDATA], eax ;store 543
  698. jz SkipDraw
  699. mov eax, [esi] ;eax = ba98
  700. add esi, 4
  701. shrd edx, eax, 16 ;edx = 9876
  702. dec ecx
  703. mov [ebp + grHOSTDATA], edx ;store 876
  704. jz SkipDraw
  705. shr eax, 8 ;eax = xba9
  706. dec ecx
  707. mov [ebp + grHOSTDATA], eax ;store ba9
  708. jnz @B
  709. ENDIF
  710. SkipDraw:
  711. REQUIRE 2, ebx
  712. cmp [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  713. je @F
  714. mov DWORD PTR [ebp + grDRAWBLTDEF], CACHE_EXPAND_XPAR
  715. mov [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  716. @@: ;enable off-screen expansion
  717. pop_ ebx
  718. pop_ edi
  719. pop_ edx
  720. pop_ eax
  721. jmp Increment
  722. ;
  723. ; Enumerate an array of glyphs.
  724. ;
  725. Enumerate:
  726. load_ 2
  727. push_ eax ;create room on stack for return
  728. push_ eax ; parameters
  729. mov eax, [pstro_] ;get pointer to STROBJ
  730. mov ebx, esp ;ebx points to pgp parameter
  731. lea ecx, [esp + 4] ;ecx points to c parameter
  732. INVOKE STROBJ_bEnum,
  733. eax,
  734. ecx,
  735. ebx
  736. pop_ ebx ;load pgp from stack
  737. pop_ ecx ;load c from stack
  738. mov [bMoreGlyphs_], eax
  739. jmp MainLoop
  740. ;
  741. ; Remove the current font from the cache. EDI holds the pointer to the font
  742. ; object.
  743. ;
  744. DestroyFont:
  745. load_ 1 ;retrieve stack state on entry
  746. INVOKE DrvDestroyFont, ;destroy font
  747. edi
  748. jmp @F
  749. ;
  750. ; We have a new font. See if the font fits into an off-screen tile by comparing
  751. ; the bounding box to 150% of the tile size. We use 150% since we might still
  752. ; be able to cache the lowercase glyphs of larger fonts.
  753. ;
  754. NewFont:
  755. ASSUME edx:PTR STROBJ
  756. mov ebx, [edx].rclBkGround.bottom
  757. ;get height of font
  758. sub ebx, [edx].rclBkGround.top
  759. cmp ebx, LINES_PER_TILE * 3 / 2
  760. ;test if small enough to fit in tile
  761. jg AbortFont ;too big
  762. ifdef WINNT_VER40
  763. @@: INVOKE EngAllocMem, ;allocate memory for font cache
  764. FL_ZERO_MEMORY,
  765. SIZEOF FONTCACHE,
  766. 'XGLC'
  767. else
  768. @@: INVOKE LocalAlloc, ;allocate memory for font cache
  769. LMEM_FIXED OR LMEM_ZEROINIT,
  770. SIZEOF FONTCACHE
  771. endif
  772. ASSUME eax:PTR FONTCACHE
  773. or eax, eax
  774. jz AbortFont ;error, not enough memory
  775. ASSUME edi:PTR FONTOBJ
  776. mov [edi].pvConsumer, eax ;store pointer to font cache in font
  777. ASSUME ebp:PTR PDEV
  778. mov ebx, [ebp].ulFontCount
  779. mov [eax].ppdev, ebp ;store pointer to device
  780. mov [eax].ulFontCount, ebx ;store current device count
  781. INVOKE AddToFontCacheChain,
  782. ebp,
  783. edi,
  784. eax
  785. jmp FontCached
  786. AbortFont:
  787. ASSUME edi:PTR FONTOBJ
  788. mov [edi].pvConsumer, -1 ;mark the font as uncacheable
  789. FontNotCached:
  790. pop_ ebx ;pass through non-cache font handler
  791. pop_ ebp
  792. pop_ esi
  793. pop_ edi
  794. jmp i386DrvTextOut
  795. Simulate:
  796. load_ 1
  797. mov [pso_], ebx ;save new surface object
  798. pop ebx ;pass through engine
  799. pop ebp
  800. pop esi
  801. pop edi
  802. jmp EngTextOut
  803. ;
  804. ; We only support simple rectangle clipping in assembly.
  805. ;
  806. CheckClipping:
  807. ASSUME ebx:PTR CLIPOBJ
  808. cmp [ebx].iDComplexity, DC_RECT
  809. jne FontNotCached
  810. DrvTextOut ENDP
  811. ;
  812. ; Right now, EAX holds the foreground brush, EBX points to the clipping object,
  813. ; EDX holds the background brush, and EBP points to the device.
  814. ;
  815. ClipTextOut PROC
  816. ASSUME eax:PTR BRUSHOBJ
  817. ASSUME ebx:PTR CLIPOBJ
  818. ASSUME edx:PTR BRUSHOBJ
  819. ASSUME ebp:PTR PDEV
  820. load_ 1
  821. cmp [ebp].iBytesPerPixel, 2
  822. push_ ebp
  823. mov ebp, [ebp].pLgREGS_real ;EBP points to Laguna registers
  824. ASSUME ebp:NOTHING
  825. mov eax, [eax].iSolidColor ;get foreground color
  826. ASSUME eax:NOTHING
  827. mov edx, [edx].iSolidColor ;get background color
  828. ASSUME edx:NOTHING
  829. ja @F
  830. je Xlate16
  831. mov ah, al ;expand 8-bpp into 16-bit
  832. mov dh, dl
  833. Xlate16:
  834. mov ecx, eax ;expand 16-bpp into 32-bit
  835. shl eax, 16
  836. mov esi, edx
  837. shl edx, 16
  838. or eax, ecx
  839. or edx, esi
  840. @@: pop_ ecx
  841. ASSUME ecx:PTR PDEV
  842. REQUIRE 4, ecx
  843. cmp [ecx].shadowFGCOLOR, eax
  844. je @F
  845. mov [ebp + grOP_opFGCOLOR], eax
  846. mov [ecx].shadowFGCOLOR, eax;store foreground color
  847. @@: mov eax, [pso_] ;get pointer to destination
  848. ASSUME eax:PTR SURFOBJ
  849. cmp [ecx].shadowBGCOLOR, edx
  850. je @F
  851. mov [ebp + grOP_opBGCOLOR], edx
  852. mov [ecx].shadowBGCOLOR, edx
  853. @@: ;store background color
  854. xor edx, edx ;zero x/y offset
  855. cmp [eax].iType, STYPE_DEVBITMAP
  856. mov eax, [eax].dhsurf ;get pointer to device bitmap
  857. ASSUME eax:PTR DSURF
  858. jne @F ;destination is not a device bitmap
  859. mov edx, [eax].packedXY ;get x/y offset of device bitmap
  860. @@: mov eax, [prclOpaque_] ;get pointer to opaquing rectangle
  861. ASSUME eax:PTR RECTL
  862. mov [mix_], edx ;store x/y offset into mix variable
  863. push_ ecx
  864. test eax, eax ;do we have an opaquing rectangle?
  865. jz SkipOpaque ;no
  866. cmp [ecx].shadowDRAWBLTDEF, SOLID_COLOR_FILL
  867. je @F
  868. REQUIRE 2, ecx
  869. mov DWORD PTR [ebp + grDRAWBLTDEF], SOLID_COLOR_FILL
  870. mov [ecx].shadowDRAWBLTDEF, SOLID_COLOR_FILL
  871. @@: ;use a solid fill
  872. mov esi, [mix_] ;get x/y offset
  873. mov edi, [eax].left ;get the rectangle coordinates
  874. mov ecx, [eax].top
  875. mov edx, [eax].right
  876. mov eax, [eax].bottom
  877. cmp edi, [ebx].rclBounds.left
  878. ;clip with clipping rectangle
  879. jg @F
  880. mov edi, [ebx].rclBounds.left
  881. @@: cmp ecx, [ebx].rclBounds.top
  882. jg @F
  883. mov ecx, [ebx].rclBounds.top
  884. @@: cmp edx, [ebx].rclBounds.right
  885. jl @F
  886. mov edx, [ebx].rclBounds.right
  887. @@: cmp eax, [ebx].rclBounds.bottom
  888. jl @F
  889. mov eax, [ebx].rclBounds.bottom
  890. @@: sub edx, edi
  891. jle SkipOpaque ;invalid width
  892. sub eax, ecx
  893. jle SkipOpaque ;invalid height
  894. IF SWAT6
  895. push esi
  896. and esi, 0000FFFFh
  897. add edi, esi
  898. pop esi
  899. shr esi, 16
  900. add ecx, esi
  901. mov esi, [esp]
  902. INVOKE StripePatBlt, esi, edi, ecx, edx, eax
  903. ELSE
  904. shl ecx, 16 ;pack x/y
  905. add edi, esi ;add x/y offset
  906. shl eax, 16
  907. add ecx, edi
  908. or eax, edx
  909. mov edx, [esp]
  910. ASSUME edx:PTR PDEV
  911. REQUIRE 5, edx
  912. mov [ebp + grOP0_opRDRAM], ecx
  913. ;draw rectangle
  914. mov [ebp + grBLTEXT_EX], eax
  915. ENDIF
  916. SkipOpaque:
  917. pop_ ecx
  918. ASSUME ecx:PTR PDEV
  919. enter_ 40 ;create stack frame
  920. bMoreGlyphs_ TEXTEQU <DWORD PTR [esp + 0 + frmPTR]>
  921. ulCharInc_ TEXTEQU <DWORD PTR [esp + 4 + frmPTR]>
  922. xBit_ TEXTEQU <DWORD PTR [esp + 8 + frmPTR]>
  923. lDelta_ TEXTEQU <DWORD PTR [esp + 12 + frmPTR]>
  924. dwControl_ TEXTEQU <DWORD PTR [esp + 16 + frmPTR]>
  925. pdev_ TEXTEQU <DWORD PTR [esp + 20 + frmPTR]>
  926. rclBounds_ TEXTEQU <RECTL PTR [esp + 24 + frmPTR]>
  927. save_ 2
  928. mov [pdev_], ecx
  929. mov ax, [ebp + grCONTROL]
  930. if DRIVER_5465 AND HW_CLIPPING
  931. cmp [ecx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR + CLIPEN
  932. je @F
  933. REQUIRE 2, ecx
  934. mov DWORD PTR [ebp + grDRAWBLTDEF], CACHE_EXPAND_XPAR + CLIPEN
  935. mov [ecx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR + CLIPEN
  936. else
  937. cmp [ecx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  938. je @F
  939. REQUIRE 2, ecx
  940. mov DWORD PTR [ebp + grDRAWBLTDEF], CACHE_EXPAND_XPAR
  941. mov [ecx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  942. endif
  943. @@: ;enable off-screen expansion
  944. mov [dwControl_], eax
  945. or eax, SWIZ_CNTL ;enable bit mirroring
  946. mov edi, [pfo_] ;EDI points to font object
  947. ASSUME edi:PTR FONTOBJ
  948. mov [ebp + grCONTROL], ax
  949. mov eax, [ebx].rclBounds.left
  950. ;get clipping coordinates
  951. mov ecx, [ebx].rclBounds.top
  952. mov edx, [ebx].rclBounds.right
  953. mov esi, [ebx].rclBounds.bottom
  954. mov ebx, [pstro_] ;EBX points to string
  955. ASSUME ebx:PTR STROBJ
  956. mov edi, [edi].pvConsumer ;EDI points to font cache
  957. ASSUME edi:PTR FONTCACHE
  958. mov [rclBounds_].left, eax ;store clipping coordinates
  959. mov [rclBounds_].top, ecx
  960. mov [rclBounds_].right, edx
  961. mov [rclBounds_].bottom, esi
  962. if DRIVER_5465 AND HW_CLIPPING
  963. ;; Set up hardware clipping
  964. shl ecx, 16 ; Top of clipping rect. in high word
  965. add eax, ecx ; Packed upper left coordinate
  966. add eax, [mix_]
  967. mov ecx, [pdev_]
  968. ASSUME ecx:PTR PDEV
  969. REQUIRE 4, ecx
  970. mov [ebp + grCLIPULE], eax ; Set upper left clipping coordinate
  971. shl esi, 16 ; Bottom of clipping rect. in high word
  972. add edx, esi ; Packed lower right coordinate
  973. add edx, [mix_]
  974. mov [ebp + grCLIPLOR], edx ; Set lower right clipping coordinate
  975. endif
  976. mov eax, [ebx].ulCharInc ;copy ulCharInc
  977. cmp [ebx].pgp, 0
  978. mov [ulCharInc_], eax
  979. je Enumerate ;there is more than one array
  980. mov ecx, [ebx].cGlyphs ;get the number of glyphs
  981. mov ebx, [ebx].pgp ;EBX points to GLYPHPOS
  982. ASSUME ebx:PTR GLYPHPOS
  983. mov [bMoreGlyphs_], 0 ;no more glyph arrays
  984. MainLoop:
  985. or ecx, ecx ;any glyphs to draw?
  986. je SkipLoop ;no
  987. mov eax, [ebx].ptl.x ;get coordinates of first glyph
  988. mov edx, [ebx].ptl.y
  989. GlyphLoop:
  990. push_ ecx
  991. mov ecx, [ebx].hg ;get the glyph handle
  992. cmp [ulCharInc_], 0 ;fixed font?
  993. jne @F ;no
  994. mov eax, [ebx].ptl.x ;get coordinates for glyph
  995. mov edx, [ebx].ptl.y
  996. @@: shl ecx, 4 ;build index into font cache array
  997. cmp ecx, MAX_GLYPHS * 16 ;glyph out of range?
  998. jnl DrawGlyph ;yes, draw it directly
  999. save_ 3
  1000. mov esi, [edi + ecx*1].aGlyphs.xyPos
  1001. ;get off-screen location of glyph
  1002. lea ecx, [edi + ecx*1].aGlyphs
  1003. ;load address of cache slot
  1004. ASSUME ecx:PTR GLYPHCACHE
  1005. or esi, esi ;is the glyph already cached?
  1006. jnz @F ;yes
  1007. mov esi, [ebx].pgdf ;cache the glyph
  1008. ASSUME esi:PTR GLYPHDEF
  1009. push eax
  1010. push edx
  1011. push ecx
  1012. INVOKE AllocGlyph,
  1013. edi,
  1014. [esi].pgb,
  1015. ecx
  1016. pop ecx
  1017. pop edx
  1018. pop eax
  1019. mov esi, [ecx].xyPos ;get off-screen location of glyph
  1020. @@: cmp [ecx].cSize, 0 ;is this an empty glyph?
  1021. jl DrawGlyph ;no, in fact it is non-cacheable
  1022. jz Increment ;yes, skip it
  1023. push_ edx
  1024. push_ eax
  1025. push_ edi
  1026. push_ ebx
  1027. add edx, [ecx].ptlOrigin.y ;EDX = top
  1028. mov edi, [ecx].cSize ;get packed width/height
  1029. add eax, [ecx].ptlOrigin.x ;EAX = left
  1030. mov ecx, edi
  1031. ASSUME ecx:NOTHING
  1032. shr edi, 16 ;EDI holds height
  1033. and ecx, 0000FFFFh ;ECX holds width
  1034. add edi, edx ;EDI = bottom
  1035. add ecx, eax ;ECX = right
  1036. mov ebx, [rclBounds_].left ;clip coordinates
  1037. ife (DRIVER_5465 AND HW_CLIPPING)
  1038. cmp ecx, [rclBounds_].right ; is the right edge clipped?
  1039. jng @F ;
  1040. mov ecx, [rclBounds_].right ; yes - set new right
  1041. endif
  1042. @@: sub ebx, eax ; is the left edge clipped?
  1043. jg SpecialDraw ; yes
  1044. sub ecx, eax ; get delta x
  1045. jng SkipGlyph ; right > left? - don't draw it
  1046. mov ebx, [rclBounds_].top
  1047. ife (DRIVER_5465 AND HW_CLIPPING)
  1048. cmp edi, [rclBounds_].bottom; is the bottom clipped?
  1049. jng @F
  1050. mov edi, [rclBounds_].bottom; yes - set new bottom
  1051. endif
  1052. @@: sub ebx, edx ; is the top clipped?
  1053. jng @F
  1054. shl ebx, 16 ; top is clipped
  1055. mov edx, [rclBounds_].top ; adjust top
  1056. add esi, ebx ; adjust off-screen top
  1057. @@: sub edi, edx ; bottom > top?
  1058. jng SkipGlyph ; no - skip it
  1059. shl edi, 16 ; pack x/y
  1060. add eax, [mix_] ; add x/y offset
  1061. shl edx, 16 ; top << 16
  1062. or edi, ecx
  1063. add edx, eax ; packed top left corner
  1064. mov ecx, [pdev_]
  1065. ASSUME ecx:PTR PDEV
  1066. REQUIRE 7, ecx
  1067. mov [ebp + grOP0_opRDRAM], edx
  1068. ;expand glyph from off-screen
  1069. mov [ebp + grOP2_opMRDRAM], esi
  1070. mov [ebp + grBLTEXT_EX], edi
  1071. SkipGlyph:
  1072. pop_ ebx
  1073. pop_ edi
  1074. pop_ eax
  1075. pop_ edx
  1076. Increment:
  1077. add eax, [ulCharInc_] ;add x-increment
  1078. pop_ ecx
  1079. add ebx, SIZEOF GLYPHPOS ;next glyph
  1080. dec ecx
  1081. jnz GlyphLoop
  1082. SkipLoop:
  1083. cmp [bMoreGlyphs_], 0 ;more arrays of glypos?
  1084. jne Enumerate ;yes
  1085. mov ecx, [dwControl_]
  1086. leave_ 40 ;kill stack frame
  1087. and ecx, NOT SWIZ_CNTL ;disable bit mirroring
  1088. mov eax, 1 ;return TRUE
  1089. mov [ebp + grCONTROL], cx
  1090. pop_ ebx
  1091. pop_ ebp
  1092. pop_ esi
  1093. pop_ edi
  1094. ret 40
  1095. Enumerate:
  1096. load_ 2
  1097. push_ eax ;create room on stack for return
  1098. push_ eax ; parameters
  1099. mov eax, [pstro_] ;get pointer to STROBJ
  1100. mov ebx, esp ;ebx points to pgp parameter
  1101. lea ecx, [esp + 4] ;ecx points to c parameter
  1102. INVOKE STROBJ_bEnum,
  1103. eax,
  1104. ecx,
  1105. ebx
  1106. pop_ ebx ;load pgp from stack
  1107. pop_ ecx ;load c from stack
  1108. mov [bMoreGlyphs_], eax
  1109. jmp MainLoop
  1110. ;//frido BEGIN 28-Mar-96
  1111. SpecialDraw:
  1112. pop_ ebx
  1113. pop_ edi
  1114. pop_ eax
  1115. pop_ edx
  1116. ;//frido END 28-Mar-96
  1117. ;
  1118. ; Draw a clipped glyph directly to screen.
  1119. ;
  1120. DrawGlyph:
  1121. load_ 3
  1122. mov esi, [ebx].pgdf ;ESI holds pointer to GLYPHDEF
  1123. ASSUME esi:PTR GLYPHDEF
  1124. push_ eax
  1125. push_ edx
  1126. mov esi, [esi].pgb ;ESI holds pointer to GLYPHBITS
  1127. ASSUME esi:PTR GLYPHBITS
  1128. push_ edi
  1129. push_ ebx
  1130. mov edi, [esi].sizlBitmap._cx
  1131. ;EDI = right
  1132. mov ecx, [esi].sizlBitmap._cy
  1133. ;ECX = bottom
  1134. add eax, [esi].ptlOrigin.x ;EAX = left
  1135. add edx, [esi].ptlOrigin.y ;EDX = top
  1136. lea ebx, [edi + 7] ;EBX = byte increment to next line
  1137. add edi, eax
  1138. shr ebx, 3
  1139. add ecx, edx
  1140. lea esi, [esi].aj ;ESI holds pointer to bits
  1141. ASSUME esi:NOTHING
  1142. mov [xBit_], 0 ;zero bit offset
  1143. mov [lDelta_], ebx
  1144. mov ebx, [rclBounds_].left
  1145. cmp edi, [rclBounds_].right ;clip right
  1146. jl @F
  1147. mov edi, [rclBounds_].right
  1148. @@: sub ebx, eax ;clip left
  1149. jng @F
  1150. mov eax, ebx ;store bit offset
  1151. shr ebx, 3
  1152. and eax, 7
  1153. add esi, ebx
  1154. mov [xBit_], eax
  1155. mov eax, [rclBounds_].left
  1156. @@: sub edi, eax ;EDI = width
  1157. jng GoIncrement
  1158. mov ebx, [rclBounds_].top
  1159. cmp ecx, [rclBounds_].bottom;clip bottom
  1160. jl @F
  1161. mov ecx, [rclBounds_].bottom
  1162. @@: sub ebx, edx ;clip top
  1163. jng @F
  1164. add edx, ebx ;store line offset
  1165. imul ebx, [lDelta_]
  1166. add esi, ebx
  1167. @@: sub ecx, edx ;ECX = height
  1168. jng GoIncrement
  1169. shl edx, 16 ;pack x,y
  1170. mov ebx, [xBit_]
  1171. shl ecx, 16
  1172. or edx, eax
  1173. or ecx, edi
  1174. add edx, [mix_] ;add x/y offset
  1175. lea edi, [edi + ebx + 7] ;EDI = adjusted width
  1176. IF broken_FIFO
  1177. IDLE
  1178. ENDIF
  1179. mov eax, [pdev_]
  1180. ASSUME eax:PTR PDEV
  1181. REQUIRE 4, eax
  1182. if DRIVER_5465 AND HW_CLIPPING
  1183. cmp [eax].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR + CLIPEN
  1184. je @F
  1185. mov DWORD PTR [ebp + grDRAWBLTDEF], TEXT_EXPAND_XPAR + CLIPEN
  1186. mov [eax].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR + CLIPEN
  1187. @@: ;enable on-screen expansion & clipping
  1188. else
  1189. cmp [eax].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR
  1190. je @F
  1191. mov DWORD PTR [ebp + grDRAWBLTDEF], TEXT_EXPAND_XPAR
  1192. mov [eax].shadowDRAWBLTDEF, TEXT_EXPAND_XPAR
  1193. @@: ;enable on-screen expansion
  1194. endif
  1195. IF SWAT7
  1196. mov [ebp + grOP2_opMRDRAM], ebx
  1197. cmp cx, 64 ;bug when doing 64 < width < 128
  1198. jbe SkipBug
  1199. cmp cx, 128
  1200. jae SkipBug
  1201. push_ ecx ;save registers
  1202. push_ edx
  1203. push_ esi
  1204. push_ edi
  1205. mov cx, 64 ;1st passs, 64 pixels
  1206. REQUIRE 5, eax
  1207. mov [ebp + grOP0_opRDRAM], edx
  1208. mov [ebp + grBLTEXT_EX], ecx
  1209. shr ecx, 16 ;get height into ECX
  1210. mov edi, [lDelta_] ;get delta
  1211. BugLoop:
  1212. mov eax, [pdev_]
  1213. REQUIRE 2, eax
  1214. mov eax, [esi][0] ;transfer 64 pixels
  1215. mov edx, [esi][4]
  1216. mov [ebp + grHOSTDATA][0], eax
  1217. mov [ebp + grHOSTDATA][4], edx
  1218. or ebx, ebx
  1219. jz @F
  1220. mov edx, [pdev_]
  1221. ASSUME edx:PTR PDEV
  1222. mov eax, [esi][8]
  1223. REQUIRE 1, edx
  1224. mov [ebp + grHOSTDATA][8], eax
  1225. @@: add esi, [lDelta_] ;next glyph line
  1226. dec ecx
  1227. jnz BugLoop
  1228. pop_ edi ;restore registers
  1229. pop_ esi
  1230. sub edi, 64 ;64 pixels less to do
  1231. pop_ edx
  1232. add esi, 64 / 8 ;8 bytes already done
  1233. pop_ ecx
  1234. add edx, 64 ;offset to next 64 pixels
  1235. sub ecx, 64
  1236. SkipBug:
  1237. mov eax, [pdev_]
  1238. ASSUME eax:PTR PDEV
  1239. shr edi, 3
  1240. REQUIRE 5, eax
  1241. mov [ebp + grOP0_opRDRAM], edx
  1242. ELSE
  1243. mov eax, [pdev_]
  1244. ASSUME eax:PTR PDEV
  1245. mov [ebp + grOP0_opRDRAM], edx
  1246. REQUIRE 5, eax
  1247. mov [ebp + grOP2_opMRDRAM], ebx
  1248. shr edi, 3
  1249. ENDIF
  1250. mov [ebp + grBLTEXT_EX], ecx
  1251. shr ecx, 16
  1252. mov edx, [lDelta_]
  1253. mov ebx, [pdev_]
  1254. ASSUME ebx:PTR PDEV
  1255. cmp edi, 2
  1256. jb Draw1Byte
  1257. je Draw2Bytes
  1258. cmp edi, 4
  1259. jbe Draw4Bytes
  1260. DrawLoop:
  1261. push_ edi
  1262. push_ esi
  1263. @@: mov eax, [esi] ;get 4 bytes from glyph
  1264. add esi, 4
  1265. REQUIRE 1, ebx
  1266. mov [ebp + grHOSTDATA], eax ;draw them
  1267. sub edi, 4 ;4 bytes done
  1268. jg @B ;still more bytes to draw
  1269. pop_ esi
  1270. pop_ edi
  1271. add esi, edx
  1272. dec ecx ;next glyph row
  1273. jnz DrawLoop
  1274. jmp SkipDraw
  1275. Draw1Byte:
  1276. mov al, [esi] ;get byte from glyph
  1277. add esi, edx
  1278. REQUIRE 1, ebx
  1279. mov [ebp + grHOSTDATA], eax ;draw it
  1280. dec ecx ;next glyph line
  1281. jnz Draw1Byte
  1282. jmp SkipDraw
  1283. Draw2Bytes:
  1284. mov ax, [esi] ;get two bytes from glyph
  1285. add esi, edx
  1286. REQUIRE 1, ebx
  1287. mov [ebp + grHOSTDATA], eax ;draw them
  1288. dec ecx ;next glyph line
  1289. jnz Draw2Bytes
  1290. jmp SkipDraw
  1291. Draw4Bytes:
  1292. mov eax, [esi] ;get four bytes from glyph
  1293. add esi, edx
  1294. REQUIRE 1, ebx
  1295. mov [ebp + grHOSTDATA], eax ;draw them
  1296. dec ecx ;next glyph line
  1297. jnz Draw4Bytes
  1298. SkipDraw:
  1299. if DRIVER_5465 AND HW_CLIPPING
  1300. cmp [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR + CLIPEN
  1301. je @F
  1302. REQUIRE 2, ebx
  1303. mov DWORD PTR [ebp + grDRAWBLTDEF], CACHE_EXPAND_XPAR + CLIPEN
  1304. mov [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR + CLIPEN
  1305. @@: ;enable off-screen expansion & clipping
  1306. else
  1307. cmp [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  1308. je @F
  1309. REQUIRE 2, ebx
  1310. mov DWORD PTR [ebp + grDRAWBLTDEF], CACHE_EXPAND_XPAR
  1311. mov [ebx].shadowDRAWBLTDEF, CACHE_EXPAND_XPAR
  1312. @@: ;enable off-screen expansion
  1313. endif
  1314. GoIncrement:
  1315. pop_ ebx
  1316. pop_ edi
  1317. pop_ edx
  1318. pop_ eax
  1319. jmp Increment
  1320. ClipTextOut ENDP
  1321. ENDIF ; USE_ASM
  1322. END