p_clr.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {
  2. Free Pascal port of the Hermes C library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C version by Christian Nentwich ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. {
  18. C surface clearing routines for the HERMES library
  19. Copyright (c) 1998 Christian Nentwich ([email protected])
  20. This source code is licensed under the GNU LGPL
  21. Please refer to the file COPYING.LIB contained in the distribution for
  22. licensing conditions
  23. }
  24. Procedure ClearP_32(iface : PHermesClearInterface); CDecl;
  25. Var
  26. count : DWord;
  27. value : int32;
  28. dest : Pchar8;
  29. Begin
  30. value := iface^.value;
  31. dest := iface^.dest;
  32. Repeat
  33. count := iface^.width;
  34. Repeat
  35. Pint32(dest)^ := value;
  36. Inc(dest, 4);
  37. Dec(count);
  38. Until count = 0;
  39. Inc(dest, iface^.add);
  40. Dec(iface^.height);
  41. Until iface^.height = 0;
  42. End;
  43. Procedure ClearP_24(iface : PHermesClearInterface); CDecl;
  44. Var
  45. p_value : Pchar8;
  46. count : DWord;
  47. dest : Pchar8;
  48. Begin
  49. p_value := @iface^.value;
  50. dest := iface^.dest;
  51. Repeat
  52. count := iface^.width;
  53. Repeat
  54. (dest + R_24)^ := (p_value + B_32)^;
  55. (dest + G_24)^ := (p_value + G_32)^;
  56. (dest + B_24)^ := (p_value + B_32)^;
  57. Inc(dest, 3);
  58. Dec(count);
  59. Until count = 0;
  60. Inc(dest, iface^.add);
  61. Dec(iface^.height);
  62. Until iface^.height = 0;
  63. End;
  64. Procedure ClearP_16(iface : PHermesClearInterface); CDecl;
  65. Var
  66. value32 : DWord;
  67. countshifted, count : DWord;
  68. dest : Pchar8;
  69. Begin
  70. value32 := (iface^.value Shl 16) Or (iface^.value And $ffff);
  71. dest := iface^.dest;
  72. Repeat
  73. count := iface^.width;
  74. { Align destination }
  75. If (PtrUInt(dest) And $3) <> 0 Then
  76. Begin
  77. Pshort16(dest)^ := iface^.value;
  78. Inc(dest, 2);
  79. Dec(count);
  80. End;
  81. countshifted := count Shr 1;
  82. While countshifted <> 0 Do
  83. Begin
  84. Dec(countshifted);
  85. Pint32(dest)^ := value32;
  86. Inc(dest, 4);
  87. End;
  88. If (count And 1) <> 0 Then
  89. Begin
  90. Pshort16(dest)^ := iface^.value;
  91. Inc(dest, 2);
  92. End;
  93. Inc(dest, iface^.add);
  94. Dec(iface^.height);
  95. Until iface^.height = 0;
  96. End;
  97. {$GOTO ON}
  98. Procedure ClearP_8(iface : PHermesClearInterface); CDecl;
  99. Label
  100. yloop;
  101. Var
  102. count, shiftcount : DWord;
  103. value32 : int32;
  104. value : char8;
  105. dest : Pchar8;
  106. Begin
  107. dest := iface^.dest;
  108. value := iface^.value And $ff;
  109. value32 := (value Shl 24) Or (value Shl 16) Or (value Shl 8) Or value;
  110. Repeat
  111. count := iface^.width;
  112. While (PtrUInt(dest) And $3) <> 0 Do { Align to dword boundary }
  113. Begin
  114. dest^ := value;
  115. Inc(dest);
  116. Dec(count);
  117. If count = 0 Then
  118. Goto yloop; { GOTO's are nice ;) }
  119. End;
  120. shiftcount := count Shr 2;
  121. While shiftcount <> 0 Do
  122. Begin
  123. Dec(shiftcount);
  124. Pint32(dest)^ := value32;
  125. Inc(dest, 4);
  126. End;
  127. count := count And $3;
  128. While count <> 0 Do
  129. Begin
  130. Dec(count);
  131. dest^ := value;
  132. Inc(dest);
  133. End;
  134. yloop:
  135. Inc(dest, iface^.add);
  136. Dec(iface^.height);
  137. Until iface^.height = 0;
  138. End;