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

  1. ;void  write_vertical(strg,col,row,color);
  2. ;  unsigned char  *strg,col,row,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _snow_protect:byte
  7.  
  8. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _write_vertical
  11. _write_vertical proc near
  12.     cld            ;direction flag forward
  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:    push ds            ;
  22.     mov  ax,_video_buffer    ;fetch _video_buffer
  23.     mov  es,ax        ;ES points to buffer
  24.     mov  bl,_snow_protect    ;fetch _snow_protect before DS change
  25.     cmp  _memory_model,2    ;data near or far?
  26.     jb   L0            ;jump if near
  27.     lds  si,dword ptr[bp+4] ;DS:SI pts to Strg
  28.     inc  bp            ;add 2 to BP since dword ptr    
  29.     inc  bp            ;
  30.     jmp  short L00        ;
  31. L0:    mov  si,[bp+4]        ;near case
  32. L00:    mov  [bp+4],bl        ;save _snow_protect
  33.     sub  ax,ax        ;
  34.     mov  al,[bp+8]        ;row to AX
  35.     dec  ax            ;count from 0
  36.     mov  dl,160        ;bytes per row
  37.     mul  dl            ;times rows
  38.     sub  dx,dx        ;
  39.     mov  dl,[bp+6]        ;column to DX
  40.     dec  dx            ;count from 0
  41.     shl  dx,1        ;double for attributes
  42.     add  ax,dx        ;add to row offset
  43.     mov  di,ax        ;ES:DI pts to screen
  44.     mov  ah,[bp+10]        ;attribute to AH
  45.     sub  cx,cx        ;clear CX
  46.     cmp  byte ptr[si],0    ;test for null string
  47.     je   L5            ;
  48. L1:    mov  al,[si]        ;char to AL
  49.     inc  si            ;inc string pointer for next time
  50.     cmp  al,0        ;test for end of string
  51.     je   L5            ;
  52.     cmp  byte ptr[bp+4],0    ;protect against snow?
  53.     je   L4            ;jump ahead if not
  54.     mov  dx,3dah        ;status byte address
  55.     mov  bx,ax        ;save char-attri in BX
  56. L2:    in   al,dx        ;get status byte
  57.     test al,1        ;test bit
  58.     jnz  L2            ;loop till 0
  59.     cli            ;disable interrupts
  60. L3:    in   al,dx        ;get status byte
  61.     test al,1        ;test bit
  62.     jz   L3            ;loop till 1
  63.     mov  ax,bx        ;return char-attri to AX
  64. L4:    stosw            ;write the char & attri
  65.     add  di,158        ;ptr to next row
  66.     jmp  short L1        ;loop
  67. L5:    sti            ;reenable interrupts
  68.     pop  ds            ;
  69.     pop  si            ;
  70.     pop  di            ;
  71.     pop  bp            ;
  72.     cmp  _memory_model,0    ;quit
  73.     jle  quit        ;
  74.     db   0CBh        ;RET far
  75. quit:    ret            ;RET near
  76. _write_vertical endp
  77. _TEXT    ENDS
  78.     END
  79.