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

  1. ;void  format_left_b(strg,distance,color);
  2. ;  unsigned char  *strg,color;
  3. ;  unsigned short  distance;
  4.  
  5.     EXTRN  _memory_model:byte
  6.     EXTRN  _video_page:byte
  7.  
  8. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _format_left_b
  11. _format_left_b proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push si            ;
  15.     cmp  _memory_model,0    ;near or far?
  16.     jle  begin        ;jump if near
  17.     inc  bp            ;else add 2 to BP
  18.     inc  bp            ;
  19. begin:    push ds            ;save DS
  20.     mov  bh,_video_page    ;place page value in BH
  21.     cmp  _memory_model,2    ;data near or far?
  22.     jb   L0            ;jump if near
  23.     lds  si,dword ptr[bp+4] ;DS:SI pts to Strg
  24.     inc  bp            ;add 2 to BP since dword ptr    
  25.     inc  bp            ;
  26.     jmp  short L00        ;
  27. L0:    mov  si,[bp+4]        ;near case
  28. L00:    cmp  byte ptr [si],0    ;test for null string
  29.     je   L4            ;    
  30.     mov  bl,[bp+8]        ;attribute to BL
  31.     mov  ah,3        ;function to get curs pos
  32.     int  10h        ;cursor pos to DH-DL
  33.     push dx            ;save starting curs pos
  34.     mov  cx,1        ;number chr wrt each time
  35. L1:    mov  al,[si]        ;get a character
  36.     cmp  al,0        ;test for end of string    
  37.     je   L3            ;
  38.     mov  ah,9        ;func to write char
  39.     int  10h        ;write the character
  40.     inc  si            ;inc string ptr
  41.     cmp  dl,79        ;right edge of screen?
  42.     je   L2            ;don't move cursor if so
  43.     inc  dl            ;inc col position
  44. L2:    mov  ah,2        ;function to set cursor
  45.     int  10h        ;forward cursor
  46.     jmp  short L1        ;loop
  47. L3:    pop  dx            ;restore cursor values
  48. L4:    mov  cx,[bp+6]        ;get new cursor offset
  49.     test cx,8000h        ;negative?
  50.     jz   L5            ;jump if not
  51.     neg  CX            ;make positive
  52.     add  dh,cl        ;add to row offset
  53.     cmp  dh,24        ;bottom of screen?
  54.     jb   L6            ;jump if not
  55.     mov  dh,24        ;else edge of screen
  56.     jmp  short L6        ;to set cursor
  57. L5:    add  dl,cl        ;add to col offset
  58.     cmp  dl,79        ;off screen?
  59.     jb   L6            ;jump if not
  60.     mov  dl,79        ;else edge of screen
  61. L6:    mov  ah,2        ;BIOS func to set curs
  62.     int  10h        ;set new cursor pos
  63.     pop  ds            ;
  64.     pop  si            ;
  65.     pop  bp            ;
  66.     cmp  _memory_model,0    ;quit
  67.     jle  quit        ;
  68.     db   0CBh        ;RET far
  69. quit:    ret            ;RET near
  70. _format_left_b endp
  71. _TEXT    ENDS
  72.     END
  73.