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

  1. ;void  display(strg,col,row,color);
  2. ;  unsigned char  *strg,col,row,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _video_page:byte
  7.     EXTRN  _snow_protect:byte
  8.  
  9. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  10.     ASSUME CS:_TEXT
  11.     PUBLIC _display
  12. _display proc near
  13.     push bp            ;
  14.     mov  bp,sp        ;set stack frame
  15.     push di            ;
  16.     push si            ;
  17.     cld            ;direction flag forward
  18.     cmp  _memory_model,0    ;near or far?
  19.     jle  begin        ;jump if near
  20.     inc  bp            ;else add 2 to BP
  21.     inc  bp            ;
  22. begin:    push ds            ;save Turbo's DS
  23.     mov  ax,_video_buffer    ;fetch _video_buffer
  24.     mov  es,ax        ;place in ES
  25.     mov  bl,_snow_protect    ;fetch _snow_protect
  26.     mov  bh,_video_page    ;fetch _video_page
  27.     cmp  _memory_model,2    ;data near or far?
  28.     jb   L0            ;jump if near
  29.     lds  si,dword ptr[bp+4] ;DS:SI pts to Strg
  30.     inc  bp            ;add 2 to bp since dword ptr
  31.     inc  bp            ;
  32.     jmp  short L00        ;
  33. L0:    mov  si,[bp+4]        ;
  34. L00:    mov  [bp+4],bx        ;save _video_page and _snow_protect
  35.     sub  ax,ax        ;
  36.     mov  al,[bp+6]        ;get Col value
  37.     mov  di,ax        ;
  38.     mov  al,[bp+8]        ;get Row value
  39.     dec  ax            ;count from 0
  40.     mov  dl,160        ;bytes per row
  41.     mul  dl            ;times rows
  42.     dec  di            ;count cols from 0
  43.     shl  di,1        ;double for attributes
  44.     add  di,ax        ;ES:DI pts to lst pos
  45.     cmp  byte ptr[si],0    ;null string?
  46.     je   L5            ;if null, set cursor and quit
  47.     mov  ah,[bp+10]        ;get attribute
  48. L1:    lodsb            ;get a character
  49.     cmp  al,0        ;end of string?
  50.     je   L5            ;
  51.     cmp  byte ptr[bp+4],0    ;protect against snow?
  52.     je   L4            ;jump ahead if not
  53.     mov  dx,3dah        ;status byte address
  54.     mov  bx,ax        ;save AH contents
  55. L2:    in   al,dx        ;get status byte
  56.     test al,1        ;test bit
  57.     jnz  L2            ;loop till 0
  58.     cli            ;disable interrupts
  59. L3:    in   al,dx        ;get status byte
  60.     test al,1        ;test bit
  61.     jz   L3            ;loop till 1
  62.     mov  ax,bx        ;restore AH contents
  63. L4:    stosw            ;write it with attribute
  64.     jmp  short L1        ;loop
  65. L5:    sti            ;reenable interrupts
  66.     mov  bh,[bp+5]        ;video page to BH
  67.     mov  ax,di        ;screen pointer
  68.     shr  ax,1        ;div by 2 for attributes
  69.     mov  cl,80        ;div by number cols
  70.     div  cl            ;make the division
  71.     mov  dh,al        ;row number
  72.     mov  dl,ah        ;col number
  73.     mov  ah,2        ;function to set cursor
  74.     int  10h        ;set curs to final pos
  75. L6:    pop  ds            ;
  76.     pop  si            ;
  77.     pop  di            ;
  78.     pop  bp            ;
  79.     cmp  _memory_model,0    ;quit
  80.     jle  quit        ;
  81.     db   0CBh        ;RET far
  82. quit:    ret            ;RET near
  83. _display endp
  84. _TEXT    ENDS
  85.     END
  86.