I_READ.asm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ; Seven Kingdoms: Ancient Adversaries
  2. ;
  3. ; Copyright 1997,1998 Enlight Software Ltd.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 2 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ;Filename : I_READ.ASM
  19. ;Description : Read a bitmap from the display surface buffer
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;----------- BEGIN OF FUNCTION IMGread ------------
  23. ;
  24. ; Put an non-compressed bitmap on image buffer.
  25. ; It does not handle color key transparency.
  26. ;
  27. ; Syntax : IMGread( imageBuf, pitch, x1, y1, x2, y2, bitmapBuf )
  28. ;
  29. ; char *imageBuf - the pointer to the display surface buffer
  30. ; int pitch - pitch of the surface buffer
  31. ; int x1, y1, x2, y2 - the read of the surface buffer to read
  32. ; char *bitmapPtr - the pointer to the bitmap buffer
  33. ;
  34. ;-------------------------------------------------
  35. ;
  36. ; Format of the bitmap data :
  37. ;
  38. ; <short> width
  39. ; <short> height
  40. ; <char..> bitmap image
  41. ;
  42. ;-------------------------------------------------
  43. PUBLIC IMGread
  44. IMGread PROC imageBuf, pitch, x1, y1, x2, y2, bitmapPtr
  45. STARTPROC
  46. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  47. MOV image_buf, EAX
  48. ;------ get the bitmap width and height -----;
  49. MOV AX , DS
  50. MOV ES , AX
  51. MOV EDI, bitmapPtr
  52. MOV EAX, x2
  53. SUB EAX, x1
  54. INC EAX ; calculate the bitmap width
  55. STOSW ; store it into the bitmap buffer
  56. MOV EBX, EAX ; store it to EBX for later internal processing
  57. MOV EAX, y2
  58. SUB EAX, y1
  59. INC EAX ; calculate the bitmap height
  60. STOSW ; store it into the bitmap buffer
  61. MOV ECX, EAX ; store it to ECX for later internal processing
  62. MOV EDX, pitch ; EDX = lineDiff
  63. SUB EDX, EBX ; lineDiff = image_width - bitmap_width
  64. CLD ; clear direction flag for MOVSB
  65. ;------- pixels copying loop --------;
  66. CALC_ADDR ESI, x1, y1, pitch ; Get the offset to the image buffer address
  67. @@putLine:
  68. PUSH ECX
  69. MOV ECX, EBX
  70. REP MOVSB
  71. ADD ESI, EDX ; EDX = lineDiff
  72. POP ECX
  73. LOOP @@putLine ; decrease the remain height and loop
  74. @@end: ENDPROC
  75. IMGread ENDP
  76. ;----------- END OF FUNCTION IMGread ----------
  77. END