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

  1. ;void  horizontal_line(hrz_char,left_col,left_row,width);
  2. ;  unsigned char  hrz_char,left_col,left_row,width;
  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 _horizontal_line
  12. _horizontal_line 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:    mov  ax,_video_buffer    ;fetch _video_buffer
  22.     mov  es,ax        ;ES pts to screen
  23.     sub  ax,ax        ;
  24.     mov  al,[bp+8]        ;get row
  25.     dec  ax            ;count from 0
  26.     mov  dl,160        ;bytes in a row
  27.     mul  dl            ;times rows    
  28.     sub  dx,dx        ;
  29.     mov  dl,[bp+6]        ;get column
  30.     dec  dx            ;count from 0
  31.     shl  dx,1        ;double for attributes
  32.     add  ax,dx        ;add to row offset
  33.     mov  di,ax        ;ES:DI pts to first char
  34.     mov  cl,[bp+10]        ;width in CL
  35.     cmp  cl,1        ;test for 0 and 1
  36.     jnbe A2            ;jump if OK
  37.     jmp  L2            ;else quit
  38. A2:    sub  cl,2        ;subtract 2 for end chars
  39.     mov  al,[bp+4]        ;ln thickness code in AL
  40.     mov  ch,0c4h        ;assume single horz line
  41.     mov  dx,0d8ceh        ;center chars for dbl ln
  42.     mov  bl,0bah        ;dbl vert char to BL
  43.     cmp  al,'D'        ;double line?
  44.     je   B2            ;jump ahead if so
  45.     cmp  al,'d'        ;double line?
  46.     je   B2            ;jump ahead if so
  47.     jmp  short D2        ;else skip over dbl code
  48. B2:    mov  ch,0CDh        ;dbl horz char to CH
  49.     mov  si,0b5b9h        ;chars for other end
  50.     mov  [bp+10],si        ;save on stack
  51.     mov  al,0ffh        ;flag to fetch char
  52.     call Writeit        ;write the character
  53.     cmp  al,bl        ;double vertical char?
  54.     jne  C2            ;jump ahead if not
  55.     mov  al,0CCh        ;char for double,double
  56.     jmp  short F2        ;ready to go, jump ahead
  57. C2:    mov  al,0c6h        ;char for double,single
  58.     jmp  short F2        ;ready to go, jump ahead
  59. D2:    mov  dx,0c5d7h        ;center chars for dbl ln
  60.     mov  si,0b4b6h        ;chars for other end
  61.     mov  [bp+10],si        ;save on stack
  62.     mov  al,0ffh        ;flag to fetch char
  63.     call Writeit        ;write the character
  64.     cmp  al,bl        ;double vertical char?
  65.     jne  E2            ;jump ahead if not
  66.     mov  al,0c7h        ;char for single,double
  67.     jmp  short F2        ;ready to go, jump ahead
  68. E2:    mov  al,0c3h        ;char for single,single
  69. F2:    mov  ah,al        ;save char in AH
  70.     mov  al,0ffh        ;flag to fetch char
  71.     inc  di            ;scrn ptr to attribute
  72.     call Writeit        ;write the character
  73.     dec  di            ;pull back pointer
  74.     xchg ah,al        ;AH-attri, AL-char
  75.     call Writeit        ;write the character
  76.     mov  bx,0b3bah        ;vertical chars in BX
  77.     or   cl,cl        ;any straight chars?
  78.     jz   K2            ;jump ahead if not
  79.     mov  al,ch        ;horizontal char to AL
  80. G2:    mov  al,0ffh        ;flag to fetch char
  81.     call Writeit        ;write the character
  82.     cmp  al,bl        ;double vertical char?
  83.     je   I2            ;jump ahead if so
  84.     mov  al,0ffh        ;flag to fetch char
  85.     call Writeit        ;write the character
  86.     cmp  al,bh        ;single verticle char?
  87.     je   H2            ;jump ahead if so
  88.     mov  al,ch        ;else single line char
  89.     jmp  short J2        ;go write it
  90. H2:    mov  al,dh        ;single center char to AL
  91.     jmp  short J2        ;go print it
  92. I2:    mov  al,dl        ;double center char to AL
  93. J2:    call Writeit        ;write the character
  94.     mov  al,ch        ;restore horizontal char
  95.     jcxz L2            ;quit if CH cleared below
  96.     dec  cl            ;decrement counter
  97.     jnz  G2            ;loop until 0
  98. K2:    mov  dx,[bp+10]        ;end chars to DX
  99.     sub  ch,ch        ;clear CH
  100.     jmp  short G2        ;go write end char
  101. L2:    sti            ;reenable interrupts
  102.     pop  si            ;
  103.     pop  di            ;
  104.     pop  bp            ;
  105.     cmp  _memory_model,0    ;quit
  106.     jle  quit        ;
  107.     db   0CBh        ;RET far
  108. quit:    ret            ;RET near
  109. _horizontal_line endp
  110. Writeit    PROC
  111.     push dx            ;save DX
  112.     push bx            ;BX too
  113.     cld            ;set direction flag
  114.     cmp  al,0FFh        ;FF=return video char
  115.     je   D1            ;jump, return char in AL
  116.     mov  dx,es        ;ES pts to video buffer
  117.     cmp  _snow_protect,0    ;protect against snow?
  118.     je   C1            ;jump ahead if so
  119.     mov  dx,3dah        ;status byte address
  120.     mov  bx,ax        ;save contents of AX
  121. A1:    in   al,dx        ;get status byte
  122.     test al,1        ;test bit
  123.     jnz  A1            ;loop till 0
  124.     cli            ;disable interrupts
  125. B1:    in   al,dx        ;get status byte
  126.     test al,1        ;test bit
  127.     jz   B1            ;loop till 1
  128.     mov  ax,bx        ;return character to AX
  129. C1:    stosw            ;write the character
  130.     jmp  short H1        ;jump ahead
  131. D1:    mov  dx,es        ;ES pts to video buffer
  132.     cmp  dx,0b800h        ;test for graphics card
  133.     jb   G1            ;jump if not graphics
  134.     mov  dx,3dah        ;status byte address
  135. E1:    in   al,dx        ;get status byte
  136.     test al,1        ;test bit
  137.     jnz  E1            ;loop till 0
  138.     cli            ;disable interrupts
  139. F1:    in   al,dx        ;get status byte
  140.     test al,1        ;test bit
  141.     jz   F1            ;loop till 1
  142. G1:    mov  al,es:[di]        ;get char for return
  143. H1:    pop  bx            ;restore BX
  144.     pop  dx            ;restore DX and return
  145.     ret            ;
  146. WriteIt    endp
  147. _TEXT    ENDS
  148.     END
  149.