home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / pctech / aug86.arc / SPRITES.ARC / SPRITES3.ASM < prev   
Assembly Source File  |  1986-04-25  |  3KB  |  103 lines

  1. ;
  2. ; *** Listing 3 ***
  3. ;
  4. ;Byte-move graphics driver for putting rectangular images into
  5. ; the Color/Graphics Adapter's medium-resolution memory map.
  6. ;
  7. ; Inputs (DS and CS must be the same, ES must contain 0B800h):
  8. ;
  9. ;   BX - Row at which to put the top of the image. Range is 0 to 198.
  10. ;      BX must be even: images cannot start at an odd row.
  11. ;
  12. ;   CX - The column at which to start the image in bytes. Range is
  13. ;      0 to 79.
  14. ;
  15. ;   SI - Points to data structure which contains the image description.
  16. ;      The first byte is the height in lines (h). The second is the
  17. ;      width of the image in bytes (w). h*w image bytes follow which
  18. ;      contain the values to be placed into the screen memory map.
  19. ;      The image bytes are ordered as h consecutive sets of w line
  20. ;      image bytes.    h must be an even number; images must be an
  21. ;      even number of scan lines high.
  22. ;
  23. ; Outputs:
  24. ;
  25. ;   None.
  26. ;
  27. ; Note: AX,BX,CX,DX,BP,SI,DI destroyed.
  28. ;
  29. cseg    segment para public 'cseg'
  30.     assume    cs:cseg,ds:cseg,es:nothing
  31.     public    byte_move_form_driver
  32. ;
  33. byte_move_form_driver proc near
  34.     mov    di,[bx+even_line_screen_offset_table]  ;find the offset of
  35.                                ; top line of image
  36.     add    di,cx     ;ES:DI now points to byte at which to put
  37.              ; the image's upper left corner
  38.     lodsb         ;get the height of the image
  39.     xor    ah,ah     ;make height a word value for calculations
  40.     mov    bx,ax     ;store height in BX
  41.     lodsb         ;get the width of the image in bytes
  42.     mov    bp,2000h ;calculate the amount to add after even scan
  43.     sub    bp,ax     ; lines are drawn to get to the address of the
  44.              ; next scan line
  45.     mov    dx,1fb0h ;calculate the amount to subtract after odd scan
  46.     add    dx,ax     ; lines are drawn to get to the address of the
  47.              ; next scan line
  48.     jmp    [bx+inline_height_vector_table-2] ;-2 because there is no
  49.                           ; zero lines entry point
  50. ;
  51. ;This table is used to find the offset of an even scan line in
  52. ; the memory map of the color graphics adapter in medium resolution mode.
  53. ;
  54. even_line_screen_offset_table label word
  55. x=0
  56.     rept    100    ;there are 100 even lines
  57.     dw    x*50h    ; each is 50h (80 decimal) long
  58. x=x+1
  59.     endm
  60. ;
  61. ;This is inline code for moving the image into the screen memory map.
  62. ;
  63. label    macro    x    ;this macro is used to label the inline code
  64. line&x&:        ; entry points
  65.     endm
  66. ;
  67. x=42            ;there will be an entry point for each even
  68.             ; number of lines between 2 and 40. They will
  69.             ; be labeled "line2", "line4", ... "line40"
  70.     rept    20
  71. x=x-2            ;calculate number of lines for this entry point
  72.     label    %x    ;put in label for entry point
  73.     mov    cx,ax    ;put width of image in bytes in CX to prepare for
  74.     rep    movsb    ; repeated move string on even line
  75.     add    di,bp    ;calculate address of next line DI + (2000h-width)
  76.     mov    cx,ax    ;put width of image in bytes in CX to prepare for
  77.     rep    movsb    ; repeated move string on odd line
  78.     sub    di,dx    ;calculate address of next line DI - (1fb0h+width)
  79.     endm
  80.     ret
  81. ;
  82. ;This table is used as an indirect address for jumping into
  83. ; the inline code for image moving.
  84. ;
  85. inline_height_vector_table label word    ;there is no entry point for zero
  86.                     ; lines. Starting at 2 eliminates
  87.                     ; the need to store a dummy entry
  88.                     ; point address
  89. entry_address    macro    x        ;this macro is used to generate
  90.         dw    line&x&     ; the labels corresponding to the
  91.         endm            ; inline code entry points
  92. ;
  93. x=2
  94.     rept    20
  95.     entry_address    %x
  96. x=x+2
  97.     endm
  98. ;
  99. byte_move_form_driver endp
  100. ;
  101. cseg    ends
  102.     end
  103.