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

  1. ;void  horizontal_line_b(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_page:byte
  7.  
  8. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  9.     ASSUME  CS:_TEXT
  10.     PUBLIC _horizontal_line_b
  11. _horizontal_line_b 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:    mov  bh,_video_page    ;set page number
  21.     mov  dl,[bp+6]        ;column to DL
  22.     dec  dl            ;count from 0
  23.     mov  dh,[bp+8]        ;row to DH
  24.     dec  dh            ;count from 0
  25.     mov  ah,2        ;function to set cursor
  26.     int  10h        ;set the cursor
  27.     mov  ah,8        ;func to read attri:char
  28.     int  10h        ;now attri:char in AH:AL
  29.     mov  cl,[bp+10]        ;width to CL
  30.     cmp  cl,1        ;test for 1 and 0
  31.     jnbe B1            ;jump ahead if OK
  32.     jmp  M1            ;else quit
  33. B1:    sub  cl,2        ;adjust for end chars
  34.     mov  bl,[bp+4]        ;ln thickness code to BL
  35.     mov  ch,0c4h        ;assume single horz line
  36.     mov  di,0d8ceh        ;center chars for dbl ln
  37.     cmp  bl,'D'        ;is it a double line?
  38.     je   C1            ;jump ahead if so
  39.     cmp  bl,'d'        ;is it double?
  40.     je   C1            ;jump ahead if so
  41.     mov  bl,0bah        ;dbl horz char to BL
  42.     jmp  short E1        ;jump ahead
  43. C1:    mov  bl,0bah        ;dbl horz char to BL
  44.     mov  ch,0cdh        ;dbl horz char to CH
  45.     mov  si,0b5b9h        ;chars for other end
  46.     cmp  al,bl        ;double vertical char?
  47.     jne  D1            ;jump ahead if not
  48.     mov  al,0cch        ;char for double,double
  49.     jmp  short G1        ;ready to go, jump ahead
  50. D1:    mov  al,0c6h        ;char for double,single
  51.     jmp  short G1        ;ready to go, jump ahead
  52. E1:    mov  di,0c5d7h        ;center chars for dbl ln
  53.     mov  si,0b4b6h        ;chars for other end
  54.     cmp  al,bl        ;double vertical char?
  55.     jne  F1            ;jump ahead if not
  56.     mov  al,0c7h        ;char for single,single
  57.     jmp  short G1        ;ready to go, jump ahead
  58. F1:    mov  al,0c3h        ;char for single,single
  59. G1:    mov  bl,ah        ;attribute to BL
  60.     mov  ah,9        ;func to write char-attri
  61.     push cx            ;save counter
  62.     mov  cx,1        ;write 1 char
  63.     int  10h        ;write the char and attri
  64.     pop  cx            ;restore counter
  65.     mov  bp,0b3bah        ;two vertical chars in BP
  66.     or   cl,cl        ;any horzntl straights?
  67.     jz   K1            ;jump ahead if not
  68. H1:    inc  dl            ;inc cursor col setting
  69.     mov  ah,2        ;function to set cursor
  70.     int  10h        ;forward the cursor
  71.     mov  ah,8        ;func to read attri:char
  72.     int  10h        ;get attri:char (AH:AL)
  73.     mov  ah,ch        ;horz straight char to AH
  74.     xchg dx,bp        ;move verticals to DX
  75.     xchg cx,di        ;move center chars to CX
  76.     cmp  al,dl        ;double vertical char?
  77.     je   I1            ;jump ahead if so
  78.     cmp  al,dh        ;single vertical char?
  79.     jne  J1            ;jump ahead if not so
  80.     mov  ah,ch        ;horizontal char to AH
  81.     jmp  short J1        ;go print it
  82. I1:    mov  ah,cl        ;double center char to AH
  83. J1:    mov  al,ah        ;transfer char to AL
  84.     xchg cx,di        ;restore counter to CX
  85.     xchg dx,bp        ;restore cursor pos to DX
  86.     mov  ah,9        ;function to write char
  87.     push cx            ;save CX values
  88.     mov  cx,1        ;write 1 char
  89.     int  10h        ;write the char and attri
  90.     pop  cx            ;restore CX values
  91.     or   si,si        ;has SI been set to 0?
  92.     jz   M1            ;quit if so
  93.     dec  cl            ;decrement counter
  94.     jnz  H1            ;loop until 0
  95. K1:    mov  di,si        ;end chars to DI
  96.     sub  si,si        ;clear SI as flag
  97.     jmp  short H1        ;go write end char
  98. M1:    pop  si            ;
  99.     pop  di            ;
  100.     pop  bp            ;
  101.     cmp  _memory_model,0    ;quit
  102.     jle  quit        ;
  103.     db   0CBh        ;RET far
  104. quit:    ret            ;RET near
  105. _horizontal_line_b endp
  106. _TEXT    ENDS
  107.     END
  108.