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

  1. ;void  char_box(ch,col,row,width,depth,color);
  2. ;  unsigned char  ch,col,row,width,depth,color;
  3.  
  4.  
  5.     EXTRN  _memory_model:byte
  6.     EXTRN  _video_buffer:word
  7.     EXTRN  _snow_protect:byte
  8.  
  9. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  10.     ASSUME  CS:_TEXT
  11.     PUBLIC _char_box
  12. _char_box proc near
  13.     push bp            ;
  14.     mov  bp,sp        ;set stack frame
  15.     push di            ;
  16.     push si            ;
  17.     cmp  _memory_model,0    ;near or far?
  18.     jle  begin        ;jump if near
  19.     inc  bp            ;else add 2 to BP
  20.     inc  bp            ;
  21. begin:    cld            ;set direction flag
  22.     mov  ax,_video_buffer    ;fetch _video_buffer
  23.     mov  es,ax        ;ES pts to screen
  24.     mov  si,bx        ;procedure addr to SI
  25.     sub  ax,ax        ;
  26.     mov  al,[bp+8]        ;get row
  27.     dec  ax            ;count from 0
  28.     mov  dl,160        ;bytes in a row
  29.     mul  dl            ;times rows
  30.     sub  dx,dx        ;
  31.     mov  dl,[bp+6]        ;get column
  32.     dec  dx            ;count from 0
  33.     shl  dx,1        ;double for attributes
  34.     add  ax,dx        ;add to row offset
  35.     mov  di,ax        ;ES:DI pts to first char
  36.     sub  bx,bx        ;
  37.     mov  bl,[bp+10]        ;width in BX
  38.     or   bx,bx        ;test for zero
  39.     jz   L6            ;quit if zero
  40.     sub  dx,dx        ;
  41.     mov  dl,[bp+12]        ;depth in DX
  42.     or   dx,dx        ;test for zero
  43.     jz   L6            ;quit if zero
  44.     mov  al,[bp+4]        ;char in AL
  45.     mov  ah,[bp+14]        ;attribute in AH
  46. L1:    mov  cx,bx        ;width to CX as counter
  47.     push di            ;save starting point
  48.     push dx            ;save depth counter
  49. L2:    cmp  _snow_protect,0    ;protect against snow?
  50.     je   L5            ;jump ahead if not
  51.     mov  dx,3dah        ;status byte address
  52.     mov  si,ax        ;save AX contents
  53. L3:    in   al,dx        ;get status byte
  54.     test al,1        ;test bit
  55.     jnz  L3            ;loop till 0
  56.     cli            ;disable interrupts
  57. L4:    in   al,dx        ;get status byte
  58.     test al,1        ;test bit
  59.     jz   L4            ;loop till 1
  60.     mov  ax,si        ;restore AX contents
  61. L5:    stosw            ;write char and attribute
  62.     loop L2            ;go do next
  63.     pop  dx            ;restore depth counter
  64.     pop  di            ;restore starting point
  65.     add  di,160        ;forward ptr one row
  66.     dec  dx            ;dec row counter
  67.     jnz  L1            ;go do next row
  68. L6:    sti            ;reenable interrupts
  69.     pop  si            ;
  70.     pop  di            ;
  71.     pop  bp            ;
  72.     cmp  _memory_model,0    ;quit
  73.     jle  quit        ;
  74.     db   0CBh        ;RET far
  75. quit:    ret            ;RET near
  76. _char_box endp
  77. _TEXT    ENDS
  78.     END
  79.