IB_R.asm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_R.ASM
  19. ;Description : Blt a bitmap to the display surface buffer with colour remapping
  20. ; but without color key transparency handling
  21. INCLUDE IMGFUN.inc
  22. .CODE
  23. ;----------- BEGIN OF FUNCTION IMGbltRemap ------------
  24. ;
  25. ; Put an non-compressed bitmap on image buffer.
  26. ; It does not handle color key transparency but colorRemapping
  27. ;
  28. ; Syntax : IMGblt( imageBuf, pitch, x, y, bitmapBuf )
  29. ;
  30. ; char *imageBuf - the pointer to the display surface buffer
  31. ; int pitch - pitch of the display surface buffer
  32. ; int x,y - where to put the image on the surface buffer
  33. ; char *bitmapPtr - the pointer to the bitmap buffer
  34. ; char *colorTable - a 256-entry color remapping table
  35. ;
  36. ;-------------------------------------------------
  37. ;
  38. ; Format of the bitmap data :
  39. ;
  40. ; <short> width
  41. ; <short> height
  42. ; <char..> bitmap image
  43. ;
  44. ;-------------------------------------------------
  45. PUBLIC IMGbltRemap
  46. IMGbltRemap PROC imageBuf, pitch, x, y, bitmapPtr, colorTable
  47. LOCAL drawWidth
  48. STARTPROC
  49. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  50. MOV image_buf, EAX
  51. ;------ get the bitmap width and height -----;
  52. MOV AX , DS
  53. MOV ES , AX
  54. MOV ESI, bitmapPtr
  55. XOR EAX, EAX
  56. LODSW ; get bitmap width
  57. MOV EBX, EAX
  58. MOV drawWidth, EAX
  59. LODSW ; get bitmap height
  60. MOV ECX, EAX
  61. MOV EDX, pitch ; EDX = lineDiff
  62. SUB EDX, EBX ; lineDiff = pitch - bitmap_width
  63. CLD ; clear direction flag for MOVSB
  64. ;------- pixels copying loop --------;
  65. CALC_ADDR EDI, x, y, pitch ; Get the offset to the image buffer address
  66. MOV EBX, colorTable
  67. @@putLine:
  68. PUSH ECX
  69. MOV ECX, drawWidth
  70. @@putPoint:
  71. LODSB
  72. XLATB [EBX]
  73. STOSB
  74. LOOP @@putPoint
  75. ADD EDI, EDX ; EDX = lineDiff
  76. POP ECX
  77. LOOP @@putLine ; decrease the remain height and loop
  78. @@end: ENDPROC
  79. IMGbltRemap ENDP
  80. ;----------- END OF FUNCTION IMGbltRemap ----------
  81. END