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

  1. ;void  save_box(box,top_x,top_y,width,depth);
  2. ;  unsigned char  *box,top_x,top_y,width,depth;
  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 _save_box
  11. _save_box 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            ;DS changed
  21.     mov  bl,_snow_protect    ;getch _snow_protect
  22.     cmp  _memory_model,2    ;data near or far?
  23.     jb   L0            ;jump if near
  24.     les  di,dword ptr[bp+4] ;ES:DI pts to Box
  25.     inc  bp            ;inc BP since dword ptr
  26.     inc  bp            ;
  27.     jmp  short L00        ;
  28. L0:    mov  ax,ds        ;shift DS to ES
  29.     mov  es,ax        ;
  30.     mov  di,[bp+4]        ;NEAR case
  31. L00:    mov  ax,_video_buffer    ;fetch video address
  32.     mov  ds,ax        ;DS points to buffer
  33.     sub  ax,ax        ;
  34.     mov  al,[bp+8]        ;row in AX
  35.     dec  ax            ;count rows from 0
  36.     mov  dl,160        ;160 bytes per row
  37.     mul  dl            ;AX times 160    
  38.     sub  dx,dx        ;
  39.     mov  dl,[bp+6]        ;col in DX
  40.     dec  dx            ;count cols from 0
  41.     shl  dx,1        ;double for attributes
  42.     add  ax,dx        ;offset of topleft corner
  43.     mov  dh,[bp+10]        ;width to DH
  44.     mov  dl,[bp+12]        ;depth to DL
  45.     sub  cx,cx        ;clear CX
  46.     cld            ;set direction flag
  47. L1:    mov  si,ax        ;set DS:SI scrn ptr
  48.     mov  cl,dh        ;width counter
  49.     push dx            ;save width, depth ctrs
  50.     push ax            ;save line start ptr
  51. L2:    or   bl,bl        ;protect against snow?
  52.     je   L5            ;jump ahead if not
  53.     mov  dx,3dah        ;status byte address
  54. L3:    in   al,dx        ;get status byte
  55.     test al,1        ;test bit
  56.     jnz  L3            ;loop till 0
  57.     cli            ;disable interrupts
  58. L4:    in   al,dx        ;get status byte
  59.     test al,1        ;test bit
  60.     jz   L4            ;loop till 1
  61. L5:    movsw            ;move word to buffer
  62.     loop L2            ;go do next in row
  63.     pop  ax            ;restore line start ptr
  64.     pop  dx            ;restore width,depth ctrs
  65.     add  ax,160        ;forward ptr to next row
  66.     dec  dl            ;dec depth counter
  67.     jnz  L1            ;loop if another line
  68. L6:    sti            ;reenable interrupts
  69.     pop  ds            ;
  70.     pop  si            ;
  71.     pop  di            ;
  72.     pop  bp            ;
  73.     cmp  _memory_model,0    ;quit
  74.     jle  quit        ;
  75.     db   0CBh        ;RET far
  76. quit:    ret            ;RET near
  77. _save_box endp
  78. _TEXT    ENDS
  79.     END
  80.