pixel.ppi 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. { internal put pixel with colour in internal format }
  12. procedure putpixeli(x,y:integer;colour:longint);
  13. var viewport:viewporttype;
  14. begin
  15. if aktviewport.clip then viewport:=aktviewport else viewport:=aktscreen;
  16. asm
  17. xorl %eax,%eax
  18. movl %eax,%ebx
  19. movw x,%bx
  20. movw y,%ax
  21. addw _AKTVIEWPORT,%bx
  22. addw _AKTVIEWPORT+2,%ax
  23. (* cmpw viewport,%bx
  24. jl p_exit // wenn x < x1 Ende
  25. cmpw -8(%ebp),%bx
  26. jg p_exit // wenn x > x2 Ende
  27. cmpw -10(%ebp),%ax
  28. jl p_exit // wenn y < y1 Ende
  29. cmpw -6(%ebp),%ax
  30. jg p_exit // wenn y > y2 Ende
  31. assumes wrong placement of viewport !!! PM *)
  32. lea viewport,%edx
  33. cmpw (%edx),%bx
  34. jl p_exit // wenn x < x1 Ende
  35. cmpw 4(%edx),%bx
  36. jg p_exit // wenn x > x2 Ende
  37. cmpw 2(%edx),%ax
  38. jl p_exit // wenn y < y1 Ende
  39. cmpw 6(%edx),%ax
  40. jg p_exit // wenn y > y2 Ende
  41. movl _Y_ARRAY(,%eax,4),%eax
  42. addl _X_ARRAY(,%ebx,4),%eax
  43. movl %eax,%esi
  44. movzbl _WINSHIFT,%ecx // { offset / winsize }
  45. shrl %cl,%eax //
  46. cmpl _A_BANK,%eax // { same bank ? }
  47. je p_dont_switch // { yep }
  48. pushl %esi
  49. pushl %eax //
  50. movl _BANKSWITCHPTR,%eax // { switchbank }
  51. call %eax //
  52. popl %esi
  53. p_dont_switch:
  54. andl _WINLOMASK,%esi
  55. movl colour,%eax
  56. addl _WBUFFER,%esi
  57. movw _SEG_WRITE,%bx
  58. movw _BYTESPERPIXEL,%cx
  59. movw %bx,%gs
  60. cmpl $2,%ecx
  61. je pp_16BPP
  62. jb pp_8BPP
  63. {$ifdef TEST_24BPP}
  64. cmpl $3,%ecx
  65. je pp_24BPP
  66. pp_32BPP:
  67. movl %eax,%gs:(%esi)
  68. jmp pp_exit
  69. pp_24BPP:
  70. movl _WINLOMASKMINUSPIXELSIZE,%edi
  71. cmpl %edi,%esi
  72. ja pp_exit
  73. movl %gs:(%esi),%edi
  74. andl $0xFF000000,%edi
  75. andl $0x00FFFFFF,%eax
  76. orl %edi,%eax
  77. movl %eax,%gs:(%esi)
  78. jmp pp_exit
  79. {$endif TEST_24BPP}
  80. pp_8BPP:
  81. movb %al,%gs:(%esi)
  82. jmp pp_exit
  83. pp_16BPP:
  84. movw %ax,%gs:(%esi)
  85. pp_exit:
  86. (* movw %dx,%ds use %gs now
  87. does not need to be kept constant PM *)
  88. p_exit:
  89. end;
  90. end; { proc }
  91. procedure putpixel(x,y:integer;colour:longint);
  92. begin
  93. colour:=convert(colour);
  94. putpixeli(x,y,colour);
  95. end;
  96. procedure pixel(offset:longint);
  97. { wird nur intern aufgerufen, umrechnung auf Viewport und Range- }
  98. { checking muessen von aufrufender Routine bereits erledigt sein }
  99. { Bankswitching wird durchgefuehrt }
  100. begin
  101. asm
  102. movl offset,%eax
  103. movl %eax,%esi
  104. movzbl _WINSHIFT,%ecx // { offset / winsize }
  105. shrl %cl,%eax //
  106. cmpl _A_BANK,%eax // { same bank ? }
  107. je dont_switch // { yep }
  108. pushl %esi
  109. pushl %eax //
  110. movl _BANKSWITCHPTR,%eax // { switchbank }
  111. call %eax //
  112. popl %esi
  113. dont_switch:
  114. movl _WINLOMASK,%eax
  115. andl %eax,%esi
  116. movl _AKTCOLOR,%eax
  117. movzwl _AKTWRITEMODE,%ecx
  118. movw _BYTESPERPIXEL,%bx
  119. addl _WBUFFER,%esi
  120. movw _SEG_WRITE,%dx
  121. movw %dx,%gs
  122. testl %ecx,%ecx
  123. jz dmove
  124. cmpl $2,%ebx
  125. je dxor16BPP
  126. jb dxor8BPP
  127. {$ifdef TEST_24BPP}
  128. cmpl $3,%ebx
  129. je dxor24BPP
  130. dxor32BPP:
  131. movl %gs:(%esi),%edx
  132. xorl %edx,%eax
  133. movl %eax,%gs:(%esi)
  134. jmp pd_exit
  135. dxor24BPP:
  136. movl _WINLOMASKMINUSPIXELSIZE,%ecx
  137. cmpl %ecx,%esi
  138. ja pd_exit
  139. movl %gs:(%esi),%edx
  140. andl $0x00FFFFFF,%eax
  141. xorl %edx,%eax
  142. movl %eax,%gs:(%esi)
  143. jmp pd_exit
  144. {$endif TEST_24BPP}
  145. dxor8BPP:
  146. xorb %al,%gs:(%esi)
  147. jmp pd_exit
  148. dxor16BPP:
  149. xorw %ax,%gs:(%esi)
  150. jmp pd_exit
  151. dmove:
  152. cmpl $2,%ebx
  153. je dmove16BPP
  154. jb dmove8BPP
  155. {$ifdef TEST_24BPP}
  156. cmpl $3,%ebx
  157. je dmove24BPP
  158. dmove32BPP:
  159. movl %eax,%gs:(%esi)
  160. jmp pd_exit
  161. dmove24BPP:
  162. movl _WINLOMASKMINUSPIXELSIZE,%ecx
  163. cmpl %ecx,%esi
  164. ja pd_exit
  165. movl %gs:(%esi),%edx
  166. andl $0xFF000000,%edx
  167. andl $0x00FFFFFF,%eax
  168. orl %edx,%eax
  169. movl %eax,%gs:(%esi)
  170. jmp pd_exit
  171. {$endif TEST_24BPP}
  172. dmove8BPP:
  173. movb %al,%gs:(%esi)
  174. jmp pd_exit
  175. dmove16BPP:
  176. movw %ax,%gs:(%esi)
  177. pd_exit:
  178. end;
  179. end; { proc }
  180. function getpixeli(x,y:integer):longint;
  181. var viewport:viewporttype;
  182. col : longint;
  183. begin
  184. if aktviewport.clip then viewport:=aktviewport else viewport:=aktscreen;
  185. asm
  186. movswl x,%ebx
  187. movswl y,%eax
  188. addw _AKTVIEWPORT,%bx
  189. addw _AKTVIEWPORT+2,%ax
  190. (* cmpw viewport,%bx
  191. jl gp_exit // wenn x < x1 Ende
  192. cmpw -8(%ebp),%bx
  193. jg gp_exit // wenn x > x2 Ende
  194. cmpw -10(%ebp),%ax
  195. jl gp_exit // wenn y < y1 Ende
  196. cmpw -6(%ebp),%ax
  197. jg gp_exit // wenn y > y2 Ende
  198. same error : viewport is assumed to be at -12
  199. that depends on alignment settings !! PM *)
  200. lea viewport,%edx
  201. cmpw (%edx),%bx
  202. jl gp_eexit // wenn x < x1 Ende
  203. cmpw 4(%edx),%bx
  204. jg gp_eexit // wenn x > x2 Ende
  205. cmpw 2(%edx),%ax
  206. jl gp_eexit // wenn y < y1 Ende
  207. cmpw 6(%edx),%ax
  208. jg gp_eexit // wenn y > y2 Ende
  209. movl _Y_ARRAY(,%eax,4),%eax
  210. addl _X_ARRAY(,%ebx,4),%eax
  211. movl %eax,%esi
  212. movzbl _WINSHIFT,%ecx // { offset / winsize }
  213. shrl %cl,%eax //
  214. cmpl _A_BANK,%eax // { same bank ? }
  215. je g_dont_switch // { yep }
  216. pushl %esi // { save Offset }
  217. pushl %eax //
  218. movl _BANKSWITCHPTR,%eax // { switchbank }
  219. call %eax //
  220. popl %esi // { restore Offset }
  221. g_dont_switch:
  222. movl _WINLOMASK,%eax
  223. andl %eax,%esi
  224. xorl %eax,%eax
  225. movzwl _BYTESPERPIXEL,%edx
  226. addl _WBUFFER,%esi
  227. movw _SEG_READ,%bx
  228. movw %bx,%gs
  229. cmpl $2,%edx // { 1 or 2 BytesPerPixel ? }
  230. je g_16BPP
  231. jb g_8BPP
  232. {$ifdef TEST_24BPP}
  233. cmpl $3,%edx // { 1 or 2 BytesPerPixel ? }
  234. je g_24BPP
  235. g_32BPP:
  236. movl %gs:(%esi),%eax
  237. andl $0x00FFFFFF,%eax
  238. jmp g_Result
  239. g_24BPP:
  240. movl _WINLOMASKMINUSPIXELSIZE,%edi
  241. cmpl %edi,%esi
  242. ja g_ErrorResult
  243. movl %gs:(%esi),%eax
  244. andl $0x00FFFFFF,%eax
  245. jmp g_Result
  246. g_ErrorResult:
  247. movl $-3,%edi
  248. addl _WINLOMASK,%edi
  249. cmpl %edi,%esi
  250. ja g_nohope
  251. decl %esi
  252. movl %gs:(%esi),%eax
  253. shrl $8,%eax
  254. jmp g_Result
  255. g_nohope:
  256. movl $0xABCDEF,%eax
  257. jmp g_Result
  258. {$endif TEST_24BPP}
  259. g_16BPP:
  260. movzwl %gs:(%esi),%eax
  261. jmp g_Result
  262. g_8BPP:
  263. movzbl %gs:(%esi),%eax
  264. jmp g_Result
  265. gp_eexit:
  266. xorl %eax,%eax
  267. jmp gp_exit
  268. g_Result:
  269. gp_exit:
  270. movl %eax,col
  271. end;
  272. getpixeli:=col;
  273. end; { proc getpixeli }
  274. function getpixel(x,y:integer):longint;
  275. begin
  276. getpixel:=unconvert(getpixeli(x,y));
  277. end; { proc }
  278. {
  279. $Log$
  280. Revision 1.5 1998-11-20 18:42:09 pierre
  281. * many bugs related to floodfill and ellipse fixed
  282. Revision 1.4 1998/11/18 13:23:36 pierre
  283. * floodfill got into an infinite loop !!
  284. + added partial support for fillpoly
  285. (still wrong if the polygon is not convex)
  286. Simply make a floodfill from the barycenter !
  287. * some 24BPP code changed (still does not work for my S3VBE program !)
  288. Revision 1.3 1998/11/18 09:31:40 pierre
  289. * changed color scheme
  290. all colors are in RGB format if more than 256 colors
  291. + added 24 and 32 bits per pixel mode
  292. (compile with -dDEBUG)
  293. 24 bit mode with banked still as problems on pixels across
  294. the bank boundary, but works in LinearFrameBufferMode
  295. Look at install/demo/nmandel.pp
  296. Revision 1.2 1998/10/22 08:22:06 pierre
  297. * mandel problem fixed !!
  298. Revision 1.1.1.1 1998/03/25 11:18:42 root
  299. * Restored version
  300. Revision 1.3 1998/01/26 11:58:33 michael
  301. + Added log at the end
  302. Working file: rtl/dos/ppi/pixel.ppi
  303. description:
  304. ----------------------------
  305. revision 1.2
  306. date: 1997/12/01 12:21:32; author: michael; state: Exp; lines: +13 -1
  307. + added copyright reference in header.
  308. ----------------------------
  309. revision 1.1
  310. date: 1997/11/27 08:33:51; author: michael; state: Exp;
  311. Initial revision
  312. ----------------------------
  313. revision 1.1.1.1
  314. date: 1997/11/27 08:33:51; author: michael; state: Exp; lines: +0 -0
  315. FPC RTL CVS start
  316. =============================================================================
  317. }