home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CEXPRESS.ZIP / GRAPHIC.ASM / SCRLHORZ.ASM < prev    next >
Assembly Source File  |  1989-05-03  |  4KB  |  128 lines

  1. ;void  scroll_horz(dir,top_x,top_y,width,depth,cols,color);
  2. ;  unsigned char  dir,top_x,top_y,width,depth,cols,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _snow_protect:byte
  7.  
  8. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _scroll_horz
  11. _scroll_horz proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    push ds            ;
  21.     mov  bl,_snow_protect    ;get _snow_protect before change DS
  22.     mov  ax,_video_buffer    ;fetch _video_buffer
  23.     mov  es,ax        ;move to ES
  24.     mov  ds,ax        ;copy in DS
  25.     sub  ax,ax        ;
  26.     mov  al,[bp+8]        ;top left row to AX
  27.     mov  [bp+8],bl        ;save _snow_protect
  28.     dec  ax            ;count from 0
  29.     cmp  ax,24        ;in range?
  30.     jna  L2            ;jump ahead if so
  31. L1:    jmp  L8            ;else quit routine
  32. L2:    mov  cl,160        ;bytes per row
  33.     mul  cl            ;times row count    
  34.     sub  cx,cx        ;
  35.     mov  cl,[bp+6]        ;top left col to CX
  36.     dec  cx            ;count from 0
  37.     cmp  cx,79        ;in range?
  38.     ja   L1            ;quit if not
  39.     shl  cx,1        ;double for attributes
  40.     add  ax,cx        ;add to row offset
  41.     sub  dx,dx        ;
  42.     mov  dl,[bp+12]        ;depth to DX
  43.     or   dx,dx        ;test for zero length
  44.     jz   L1            ;quit if zero
  45.     mov  cl,[bp+4]        ;get direction flag
  46.     cmp  cl,'L'        ;test for 'L'
  47.     je   L3            ;jump ahead if 'L'
  48.     cmp  cl,'l'        ;test for 'l'
  49.     je   L3            ;jump ahead if 'l'    
  50.     sub  cx,cx        ;
  51.     mov  cl,[bp+10]        ;width to CX
  52.     dec  cx            ;adjust
  53.     shl  cx,1        ;double for attributes
  54.     add  ax,cx        ;add to x,y position
  55.     mov  di,ax        ;ES:DI pts to top right
  56.     sub  cx,cx        ;
  57.     mov  cl,[bp+14]        ;get cols to scroll
  58.     shl  cx,1        ;double for attributes
  59.     sub  ax,cx        ;sub from top right pos
  60.     mov  si,ax        ;DS:SI pts to source
  61.     std            ;set direction for 'R'
  62.     jmp  short L4        ;jump ahead
  63. L3:    sub  cx,cx        ;
  64.     mov  cl,[bp+14]        ;cols to CX
  65.     shl  cx,1        ;double for attributes
  66.     mov  di,ax        ;ES:DI pts leftmost char
  67.     add  ax,cx        ;offset to lst scrl char
  68.     mov  si,ax        ;DS:SI pts scrl char
  69.     cld            ;set direction for 'L'
  70. L4:    sub  cx,cx        ;
  71.     mov  cl,[bp+10]        ;box width to DX
  72.     or   cx,cx        ;test for zero width
  73.     jz   L8            ;quit routine if zero
  74.     sub  ax,ax        ;
  75.     mov  al,[bp+14]        ;number cols to scroll
  76.     or   ax,ax        ;test for zero cols
  77.     jnz  L5            ;jump ahead if not zero
  78.     xchg ax,cx        ;else cols = width
  79.     jmp  short L6        ;jump ahead
  80. L5:    sub  cx,ax        ;width minus cols
  81.     cmp  cx,0        ;more cols than width?
  82.     jge  L6            ;jump ahead if not    
  83.     sub  ax,ax        ;
  84.     mov  al,[bp+10]        ;else cols = width
  85.     mov  cx,0        ;scroll = 0
  86. L6:    push ax            ;save number cols
  87.     push cx            ;save width counter
  88.     push si            ;save source ptr
  89.     push di            ;save destination ptr
  90.     push dx            ;save row counter
  91.     push ax            ;save number cols
  92.     cmp  byte ptr[bp+8],0    ;protect against snow?
  93.     je   L7            ;jump ahead if not
  94.     mov  dx,3D8H        ;CGA mode select register
  95.     mov  al,25h        ;shut off screen
  96.     out  dx,al        ;do it
  97. L7:    pop  ax            ;restore number cols
  98.     pop  dx            ;restore row counter
  99.     rep  movsw        ;move a row
  100.     mov  cx,ax        ;number cols scrolled
  101.     mov  al,32        ;clear with spc char
  102.     mov  ah,[bp+16]        ;attribute for clear
  103.     rep  stosw        ;clear opened area
  104.     pop  di            ;restore destination ptr
  105.     add  di,160        ;forward to next line
  106.     pop  si            ;restore source ptr
  107.     add  si,160        ;forward to next line
  108.     pop  cx            ;restore width counter
  109.     pop  ax            ;restore num cols
  110.     dec  dx            ;dec the row counter
  111.     jnz  L6            ;loop until finished
  112.     cmp  byte ptr[bp+8],0    ;protected against snow?
  113.     je   L8            ;jump if not
  114.     mov  dx,3D8H        ;CGA mode select register
  115.     mov  al,41        ;80x25, blink enabled
  116.     out  dx,al        ;reenable video
  117. L8:    pop  ds            ;
  118.     pop  si            ;
  119.     pop  di            ;
  120.     pop  bp            ;
  121.     cmp  _memory_model,0    ;quit
  122.     jle  quit        ;
  123.     db   0CBh        ;RET far
  124. quit:    ret            ;RET near
  125. _scroll_horz endp
  126. _TEXT    ENDS
  127.     END
  128.