pixel.ppi 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. procedure putpixel(x,y:integer;colour:longint);
  12. var viewport:viewporttype;
  13. begin
  14. if aktviewport.clip then viewport:=aktviewport else viewport:=aktscreen;
  15. asm
  16. xorl %eax,%eax
  17. movl %eax,%ebx
  18. movw x,%bx
  19. movw y,%ax
  20. addw _AKTVIEWPORT,%bx
  21. addw _AKTVIEWPORT+2,%ax
  22. cmpw viewport,%bx
  23. jl p_exit // wenn x < x1 Ende
  24. cmpw -8(%ebp),%bx
  25. jg p_exit // wenn x > x2 Ende
  26. cmpw -10(%ebp),%ax
  27. jl p_exit // wenn y < y1 Ende
  28. cmpw -6(%ebp),%ax
  29. jg p_exit // wenn y > y2 Ende
  30. movl _Y_ARRAY(,%eax,4),%eax
  31. addl _X_ARRAY(,%ebx,4),%eax
  32. movl %eax,%esi
  33. movl _WINSHIFT,%ecx // { offset / winsize }
  34. shrl %cl,%eax //
  35. cmpl _AW_BANK,%eax // { same bank ? }
  36. je p_dont_switch // { yep }
  37. movl %eax,_AW_BANK // { newbank }
  38. pushl %eax //
  39. movl _BANKSWITCHPTR,%eax // { switchbank }
  40. call %eax //
  41. p_dont_switch:
  42. andl _WINLOMASK,%esi
  43. movl colour,%eax
  44. addl _WBUFFER,%esi
  45. movw _SEG_WRITE,%bx
  46. movw _BYTESPERPIXEL,%cx
  47. movw %ds,%dx
  48. movw %bx,%ds
  49. testl $1,%ecx
  50. jz pp_2BPP
  51. movb %al,(%esi)
  52. jnz pp_exit
  53. pp_2BPP:
  54. movw %ax,(%esi)
  55. pp_exit:
  56. movw %dx,%ds
  57. p_exit:
  58. end;
  59. end; { proc }
  60. procedure pixel(offset:longint);
  61. { wird nur intern aufgerufen, umrechnung auf Viewport und Range- }
  62. { checking muessen von aufrufender Routine bereits erledigt sein }
  63. { Bankswitching wird durchgefuehrt }
  64. begin
  65. asm
  66. movl offset,%eax
  67. movl %eax,%esi
  68. movl _WINSHIFT,%ecx // { offset / winsize }
  69. shrl %cl,%eax //
  70. cmpl _AW_BANK,%eax // { same bank ? }
  71. je dont_switch // { yep }
  72. movl %eax,_AW_BANK // { newbank }
  73. pushl %eax //
  74. movl _BANKSWITCHPTR,%eax // { switchbank }
  75. call %eax //
  76. dont_switch:
  77. movl _WINLOMASK,%eax
  78. andl %eax,%esi
  79. movl _AKTCOLOR,%eax
  80. movzwl _AKTWRITEMODE,%ecx
  81. movw _BYTESPERPIXEL,%bx
  82. addl _WBUFFER,%esi
  83. movw _SEG_WRITE,%dx
  84. movw %ds,%di
  85. movw %dx,%ds
  86. testl %ecx,%ecx
  87. jz dmove
  88. shrl %ebx
  89. jnc dxor2BPP
  90. xorb %al,(%esi)
  91. jnc pd_exit
  92. dxor2BPP:
  93. xorw %ax,(%esi)
  94. jnc pd_exit
  95. dmove:
  96. shrl %ebx
  97. jnc dmove2BPP
  98. movb %al,(%esi)
  99. jc pd_exit
  100. dmove2BPP:
  101. movw %ax,(%esi)
  102. pd_exit:
  103. movw %di,%ds
  104. end;
  105. end; { proc }
  106. function getpixel(x,y:integer):longint;
  107. var viewport:viewporttype;
  108. begin
  109. if aktviewport.clip then viewport:=aktviewport else viewport:=aktscreen;
  110. asm
  111. movswl x,%ebx
  112. movswl y,%eax
  113. addw _AKTVIEWPORT,%bx
  114. addw _AKTVIEWPORT+2,%ax
  115. cmpw viewport,%bx
  116. jl gp_exit // wenn x < x1 Ende
  117. cmpw -8(%ebp),%bx
  118. jg gp_exit // wenn x > x2 Ende
  119. cmpw -10(%ebp),%ax
  120. jl gp_exit // wenn y < y1 Ende
  121. cmpw -6(%ebp),%ax
  122. jg gp_exit // wenn y > y2 Ende
  123. movl _Y_ARRAY(,%eax,4),%eax
  124. addl _X_ARRAY(,%ebx,4),%eax
  125. movl %eax,%esi
  126. movl _WINSHIFT,%ecx // { offset / winsize }
  127. shrl %cl,%eax //
  128. cmpl _AW_BANK,%eax // { same bank ? }
  129. je g_dont_switch // { yep }
  130. pushl %esi // { save Offset }
  131. movl %eax,_AW_BANK // { newbank }
  132. pushl %eax //
  133. movl _BANKSWITCHPTR,%eax // { switchbank }
  134. call %eax //
  135. popl %esi // { restore Offset }
  136. g_dont_switch:
  137. movl _WINLOMASK,%eax
  138. andl %eax,%esi
  139. xorl %eax,%eax
  140. movl _BYTESPERPIXEL,%edx
  141. addl _WBUFFER,%esi
  142. movw _SEG_WRITE,%bx
  143. movw %ds,%cx
  144. movw %bx,%ds
  145. testl $1,%edx // { 1 or 2 BytesPerPixel ? }
  146. jnz g_8BPP
  147. movw %ds:(%esi),%ax
  148. jnz g_Result
  149. g_8BPP:
  150. movb %ds:(%esi),%al
  151. g_Result:
  152. movw %cx,%ds
  153. movl %eax,__RESULT
  154. gp_exit:
  155. end;
  156. end; { proc }
  157. {
  158. $Log$
  159. Revision 1.1 1998-03-25 11:18:42 root
  160. Initial revision
  161. Revision 1.3 1998/01/26 11:58:33 michael
  162. + Added log at the end
  163. Working file: rtl/dos/ppi/pixel.ppi
  164. description:
  165. ----------------------------
  166. revision 1.2
  167. date: 1997/12/01 12:21:32; author: michael; state: Exp; lines: +13 -1
  168. + added copyright reference in header.
  169. ----------------------------
  170. revision 1.1
  171. date: 1997/11/27 08:33:51; author: michael; state: Exp;
  172. Initial revision
  173. ----------------------------
  174. revision 1.1.1.1
  175. date: 1997/11/27 08:33:51; author: michael; state: Exp; lines: +0 -0
  176. FPC RTL CVS start
  177. =============================================================================
  178. }