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

  1. ;void  draw_box_b(hrz_char,vrt_char,top_x,top_y,width,depth,color);
  2. ;  unsigned char  hrz_char,vrt_char,top_x,top_y,width,depth,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _error_code:byte
  6.     EXTRN  _video_page:byte
  7.  
  8. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  9.     ASSUME  CS:_TEXT
  10.     PUBLIC _draw_box_b
  11. _draw_box_b proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set up 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  _error_code,1    ;1 = row out of range
  21.     mov  dh,[bp+10]        ;top left row
  22.     dec  dh            ;count from 0
  23.     cmp  dh,24        ;in range?
  24.     jna  A1            ;jump ahead if so
  25.     jmp  P1            ;else quit
  26. A1:    inc  _error_code    ;2 = col out of range
  27.     mov  dl,[bp+8]        ;top left col
  28.     dec  dl            ;count from 0
  29.     cmp  dl,79        ;in range?
  30.     jna  B1            ;jump ahead if so
  31.     jmp  P1            ;else quit
  32. B1:    inc  _error_code    ;3 = width out of range
  33.     mov  bh,_video_page    ;get page number
  34.     mov  bl,[bp+16]        ;attribute to BL
  35.     mov  ah,2        ;func to set cursor
  36.     int  10h        ;set initial cursor
  37.     mov  cl,[bp+6]        ;get vertical char type
  38.     cmp  cl,'D'        ;is it double?
  39.     je   C1            ;jump ahead if so
  40.     cmp  cl,'d'        ;is it double?
  41.     je   C1            ;jump ahead if so
  42.     mov  al,0B3H        ;single vert char
  43.     mov  ch,0        ;flag single vert chars
  44.     jmp  short D1        ;jump ahead
  45. C1:    mov  al,0BAH        ;double vert char
  46.     mov  ch,1        ;flag double vert chars
  47. D1:    mov  cl,[bp+4]        ;get horz char type
  48.     mov  ah,0cdh        ;assume double horz char
  49.     cmp  cl,'D'        ;is it double?
  50.     je   F1            ;jump ahead if so
  51.     cmp  cl,'d'        ;is it double?
  52.     je   F1            ;jump ahead if so
  53.     mov  ah,0C4H        ;single horz char
  54.     cmp  ch,0        ;single vert chars?
  55.     je   E1            ;jump ahead if so
  56.     mov  di,0d6b7h        ;top dbl vert, sngl horz
  57.     mov  si,0d3bdh        ;bot dbl vert, sngl horz
  58.     jmp  short H1        ;jump ahead
  59. E1:    mov  di,0dabfh        ;top sngl vert, sngl horz
  60.     mov  si,0c0d9h        ;bot sngl vert, sngl horz
  61.     jmp  short H1        ;jump ahead
  62. F1:    cmp  ch,0        ;single vert chars?
  63.     je   G1            ;jump ahead if so
  64.     mov  di,0c9bbh        ;top dbl vert, dbl horz
  65.     mov  si,0c8bch        ;bot dbl vert, dbl horz
  66.     jmp  short H1        ;jump ahead
  67. G1:    mov  di,0d5b8h        ;top sngl vert, dbl horz
  68.     mov  si,0d4beh        ;bot sngl vert, dbl horz
  69. H1:    mov  [bp+4],di        ;save top corners
  70.     mov  [bp+6],si        ;save bottom corners
  71.     mov  [bp+10],ax        ;save vert/horz chars
  72.     mov  cx,1        ;number chars to write
  73.     mov  al,[bp+5]        ;top left char
  74.     mov  ah,9        ;func to write
  75.     int  10h        ;write the char
  76.     sub  cx,cx        ;
  77.     mov  cl,[bp+12]        ;width to CX
  78.     sub  cx,2        ;adjust for end chars
  79.     cmp  cx,78        ;in range?
  80.     jna  I1            ;jump ahead if so
  81.     jmp  P1            ;else quit
  82. I1:    inc  _error_code    ;4 = depth out of range
  83.     push cx            ;save width for later
  84.     push dx            ;save initial cursor pos
  85.     inc  dl            ;inc column
  86.     jcxz J1            ;jump ahead if zero
  87.     mov  ah,2        ;function number
  88.     int  10h        ;reset cursor
  89.     mov  ah,9        ;ready for write function
  90.     mov  al,[bp+11]        ;get horz char
  91.     int  10h        ;write line of chars
  92. J1:    add  dl,cl        ;add offset to right end
  93.     mov  ah,2        ;function number
  94.     int  10h        ;reset cursor
  95.     mov  ah,9        ;ready for write function
  96.     mov  cx,1        ;write 1 char
  97.     mov  al,[bp+4]        ;top right char
  98.     int  10h        ;write it
  99.     push cx            ;
  100.     sub  cx,cx        ;
  101.     mov  cl,[bp+14]        ;depth to DI
  102.     mov  di,cx        ;
  103.     pop  cx            ;
  104.     sub  di,2        ;adjust for end chars
  105.     cmp  di,23        ;in range?
  106.     ja   O1            ;quit if not
  107.     mov  _error_code,0    ;else no error
  108.     push di            ;save depth counter
  109.     cmp  di,0        ;test for zero depth
  110.     je   L1            ;jump ahead if zero
  111. K1:    inc  dh            ;inc column
  112.     mov  ah,2        ;function number
  113.     int  10h        ;reset cursor
  114.     mov  ah,9        ;ready for write function
  115.     mov  al,[bp+10]        ;get vert char
  116.     int  10h        ;write the char
  117.     dec  di            ;dec counter
  118.     jnz  K1            ;loop till finished
  119. L1:    inc  dh            ;inc column
  120.     mov  ah,2        ;function number
  121.     int  10h        ;reset cursor
  122.     mov  ah,9        ;ready for write function
  123.     mov  al,[bp+6]        ;bottom right char
  124.     int  10h        ;write it
  125.     pop  di            ;restore depth counter
  126.     pop  dx            ;restore initial cursor
  127.     or   di,di        ;test for zero depth
  128.     jz   N1            ;jump ahead if zero
  129. M1:    inc  dh            ;inc column
  130.     mov  ah,2        ;function number
  131.     int  10h        ;reset cursor
  132.     mov  ah,9        ;ready for write function
  133.     mov  al,[bp+10]        ;get vertical char
  134.     int  10h        ;write it
  135.     dec  di            ;dec counter
  136.     jnz  M1            ;loop until finished
  137. N1:    inc  dh            ;inc row
  138.     mov  ah,2        ;function number
  139.     int  10h        ;reset cursor
  140.     mov  ah,9        ;ready for write function
  141.     mov  al,[bp+7]        ;bottom left char
  142.     int  10h        ;write it
  143.     inc  dl            ;inc column
  144.     pop  cx            ;width
  145.     jcxz P1            ;quit if zero
  146.     mov  ah,2        ;function number
  147.     int  10h        ;reset cursor
  148.     mov  ah,9        ;ready for write function
  149.     mov  al,[bp+11]        ;get horizontal char
  150.     int  10h        ;write line of chars
  151.     jmp  short P1        ;jump ahead
  152. O1:    add  sp,4        ;balance stack
  153. P1:    pop  si            ;
  154.     pop  di            ;
  155.     pop  bp            ;
  156.     cmp  _memory_model,0    ;quit
  157.     jle  quit        ;
  158.     db   0CBh        ;RET far
  159. quit:    ret            ;RET near
  160. _draw_box_b endp
  161. _TEXT    ENDS
  162.     END
  163.