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

  1. ;void  format_right_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_right_b
  11. _format_right_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:    push ds            ;save DS
  21.     mov  bh,_video_page    ;place page value in BH
  22.     cmp  _memory_model,2    ;data near or far?
  23.     jb   L0            ;jump if near
  24.     lds  si,dword ptr[bp+4] ;DS:SI pts to Strg
  25.     inc  bp            ;add 2 to BP since dword ptr    
  26.     inc  bp            ;
  27.     jmp  short L00        ;
  28. L0:    mov  si,[bp+4]        ;near case
  29. L00:    sub  cx,cx        ;clear CX
  30.     cmp  byte ptr[si],0    ;test for null string
  31.     je   L3            ;
  32. L000:    inc  si            ;move SI to end of string
  33.     inc  cx            ;inc string length counter
  34.     cmp  byte ptr[si],0    ;test for end of string
  35.     jne  L000        ;loop
  36.     dec  si            ;pull back pointer
  37.     mov  di,cx        ;DI counts string len
  38.     mov  bl,[bp+8]        ;attribute to BL
  39.     mov  ah,3        ;function to get curs pos
  40.     int  10h        ;cursor pos to DH-DL
  41.     push dx            ;save starting curs pos
  42.     mov  cx,1        ;number chr wrt each time
  43. L1:    mov  al,[si]        ;get a character
  44.     mov  ah,9        ;func to write char
  45.     int  10h        ;write the character
  46.     dec  si            ;dec string ptr
  47.     cmp  dl,0        ;left edge of screen?
  48.     je   L2            ;don't move cursor if so
  49.     dec  dl            ;dec col position
  50. L2:    mov  ah,2        ;function to set cursor
  51.     int  10h        ;forward cursor
  52.     dec  di            ;dec string len ctr
  53.     jnz  L1            ;loop till finished
  54.     pop  dx            ;restore cursor values
  55. L3:    mov  cx,[bp+6]        ;get new cursor offset
  56.     test cx,8000h        ;negative?
  57.     jz   L4            ;jump if not
  58.     neg  CX            ;make positive
  59.     add  dh,cl        ;add to row offset
  60.     cmp  dh,24        ;bottom of screen?
  61.     jb   L5            ;jump if not
  62.     mov  dh,24        ;else edge of screen
  63.     jmp  short L5        ;to set cursor
  64. L4:    add  dl,cl        ;add to col offset
  65.     cmp  dl,79        ;off screen?
  66.     jb   L5            ;jump if not
  67.     mov  dl,79        ;else edge of screen
  68. L5:    mov  ah,2        ;BIOS func to set curs
  69.     int  10h        ;set new cursor pos
  70.     pop  ds            ;
  71.     pop  si            ;
  72.     pop  di            ;
  73.     pop  bp            ;
  74.     cmp  _memory_model,0    ;quit
  75.     jle  quit        ;
  76.     db   0CBh        ;RET far
  77. quit:    ret            ;RET near
  78. _format_right_b endp
  79. _TEXT    ENDS
  80.     END
  81.