home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / assemutl.zip / DISPTEXT.ASM < prev    next >
Assembly Source File  |  1985-05-15  |  6KB  |  232 lines

  1.     page    ,132
  2. ;------------------------------------------------------------
  3. ;
  4. ; PROGRAM:
  5. ;
  6. ;    This routine tests DISP_TEXT which prints a string
  7. ;    on the screen without using BIOS interupts.
  8. ;
  9. ; Author: Malcolm McCorquodale III.
  10. ; Date    : July 1983.
  11. ;
  12. ;------------------------------------------------------------
  13. ;
  14. ; BIOS data areas.
  15. ;
  16. intdata     segment at 40h
  17.         org    10h
  18. equip_flag    dw    ?        ;installed hardware
  19. ;----------------------------------
  20. ; video display data area
  21. ;----------------------------------
  22.         org    49h
  23. crt_mode    db    ?    ; Current crt mode
  24. crt_cols    dw    ?    ; Number of columns on screen
  25. crt_len     dw    ?    ; Length of regen in bytes
  26. crt_start    dw    ?    ; Startimg address in regen buffer
  27. cursor_posn    dw    8 dup(?) ; Cursor for each of up to 8 pages
  28. cursor_mode    dw    ?    ; Current cursor mode setting
  29. active_page    db    ?    ; Current page being displayed
  30. addr_6845    dw    ?    ; Base address for active display card
  31. crt_mode_set    db    ?    ; Current setting of the 3x8 register
  32. crt_pallette    db    ?    ; Current pallette setting color card
  33. intdata     ends
  34.  
  35. ;----------------------------------
  36. ; myprog's data area.
  37. ;----------------------------------
  38. data    segment 'data'
  39. string1 db    100 dup (31h)    ; The number 1
  40. string2 db    100 dup (32h)    ; The number 2
  41. data    ends
  42.  
  43. ;--------------------------------
  44. ; Stack segment
  45. ;--------------------------------
  46. stack    segment stack 'stack'
  47. stk    db    24 dup (?)
  48. stack    ends
  49.  
  50. ;----------------------------------------------------
  51. ;
  52. ; This routine prints a character to the screen
  53. ;    without using BIOS interupts.
  54. ;
  55. ;----------------------------------------------------
  56. code    segment 'code'
  57.     assume    CS:code,DS:data,SS:stack
  58.  
  59. myprog    proc    far
  60.             ; DOS linkage.
  61.     push    ds    ; Save return segment address on stack.
  62.     xor    ax,ax    ; Zero out ax reg,
  63.     push    ax    ;   and place on stack.
  64.     mov    ax,data  ;
  65.     mov    ds,ax     ; Establish addressibility,
  66.              ;   for DATA segment.
  67. ;
  68. ; Set up for and simulate a INT 10h with ah = 10
  69. ;
  70.     mov    ah,0         ; Write on row 6
  71.     mov    al,0         ;  column 10
  72.     mov    bh,0         ;  on page 0
  73.     mov    cx,length string1 ; 1000 characters
  74.     mov    si,offset string1
  75.     call    disp_text
  76.  
  77.     mov    ah,0         ; Write on row 6
  78.     mov    al,0         ;  column 10
  79.     mov    bh,0         ;  on page 0
  80.     mov    cx,length string2 ; 1000 characters
  81.     mov    si,offset string2
  82.     call    disp_text
  83.     ret
  84. myprog    endp
  85.  
  86. ;-------------------------------------------------------------
  87. ;
  88. ; DISP_TEXT
  89. ;
  90. ; This routine will print N characters on the screen.
  91. ;
  92. ; INPUT
  93. ;    (ah)    = Row to start printing data on.
  94. ;    (al)    = Column to start printing data on.
  95. ;    (bh)    = Number of page to use.
  96. ;    (cx)    = Number of characters to write.
  97. ;    (ds:si) = Address of message to print on screen.
  98. ;
  99. ; OUTPUT
  100. ;    None.
  101. ;
  102. ;-------------------------------------------------------------
  103. DISP_TEXT    proc    near
  104.     assume    ds:intdata    ; Use intdata as data segment.
  105.     sti        ; Restore interupts.
  106.     cld        ; Set direction forward.
  107.     push    es    ; Save registers on stack.
  108.     push    dx
  109.     push    cx
  110.     push    bx
  111.     push    si
  112.     push    di
  113.     push    ds
  114.     push    ax    ; save row, column value.
  115.  
  116.     mov    ax,intdata    ; Establish addressibility for
  117.     mov    ds,ax        ;   DISP_TEXT procs.
  118.     mov    ax,0b800h    ; Color card segment
  119.     mov    di,equip_flag    ; Get equipment setting
  120.     and    di,30h        ; Isolate CRT switches
  121.     cmp    di,30h        ;   Is setting for B&W card?
  122.     jne    skip_bw
  123.     mov    ax,0b000h    ;   If B&W reset address.
  124. skip_bw:
  125.     mov    es,ax        ; Set up ES to point at video ram areas.
  126.     mov    ah,crt_mode    ; Move the CRT mode into ah.
  127.     jmp    write_character ; Jump over Write_Character's subroutines.
  128. DISP_TEXT    endp
  129.  
  130. ;--------------------------------------------------------------------
  131. ;
  132. ; FIND_POSITION
  133. ;
  134. ;    These routines convert the row and column contained in AX
  135. ;    to the offset required for screen memory. (The regen buffer).
  136. ;    This routine works for alphanumeric modes.
  137. ;
  138. ; INPUT
  139. ;    ax = row, column position for characters.
  140. ;
  141. ; OUTPUT
  142. ;    ax = offset of char position in regen buffer.
  143. ;
  144. ;--------------------------------------------------------------------
  145.  
  146. Find_position    proc    near
  147.     push    cx
  148.     mov    cl,bh        ; display page to cx
  149.     xor    ch,ch
  150.     xor    bx,bx        ; Assume screen 0.
  151.     jcxz    no_page
  152. page_loop:            ; If we are not on screen 0 then
  153.     add    bx,crt_len    ;    adjust bx for the page we're on.
  154.     loop    page_loop
  155. no_page:
  156.  
  157.     push    bx        ; Save work register
  158.     mov    bx,ax
  159.     mov    al,ah        ; Move rows to al.
  160.     mul    byte ptr crt_cols    ; Determine # of bytes to row.
  161.     xor    bh,bh
  162.     add    ax,bx        ; Add in column value.
  163.     sal    ax,1        ; Times 2 for attribute bytes.
  164.     pop    bx        ; Restore work register
  165.  
  166.     add    bx,ax        ; Add to start of screen buffer.
  167.     pop    cx
  168.     ret
  169. find_position    endp
  170.  
  171. ;----------------------------------------------------------------------
  172. ;
  173. ; WRITE_CHARACTER
  174. ;
  175. ;    This routine writes the characters at
  176. ;    the calculated cursor position, with attribute unchanged.
  177. ;
  178. ;    This procedure could be changed to write the attribute
  179. ;    byte also. This would require changing the MOVSB instruction
  180. ;    to a MOVSW instruction as well as deleting the INC DI
  181. ;    instruction that follows it.
  182. ;
  183. ;----------------------------------------------------------------------
  184.  
  185. write_character proc    near
  186.     cmp    ah,4        ; Is this graphics ?
  187.     jc    begin
  188.     cmp    ah,7        ; Is this the b&w card ?
  189.     je    begin
  190.     pop    ax        ; Throw away ax,
  191.     ret            ;   and abort.
  192. begin:
  193.     pop    ax        ; Restore row and column.
  194.     call    find_position    ; Calculate address at which to
  195.     mov    di,bx        ;   put text, and put it in di.
  196. ;
  197. ;------Wait for horizontal retrace.
  198. ;
  199. wait_retrace:
  200.     mov    dx,addr_6845    ; Get base address of 6845 screen controller,.
  201.     add    dx,6        ;     and point at 6845 status port.
  202.     pop    ds        ; Restore users Data segment so we can
  203.     assume    ds:data     ;      find and print his data.
  204. wait_low:
  205.     in    al,dx        ; Get status.
  206.     test    al,1        ; Is it low ?
  207.     jnz    wait_low    ; Wait until it is.
  208.     cli            ; Mask out interupts.
  209. wait_high:
  210.     in    al,dx        ; Get status.
  211.     test    al,1        ; Is it high ?
  212.     jz    wait_high    ; Wait until it is.
  213.     movsb            ; Put the the char/attr
  214.     inc    di        ; Bump pointer past attribute byte.
  215.     loop    wait_low    ;   as many times as requested.
  216. ;
  217. ;  Return to caller.
  218. ;
  219.     sti        ; reallow interupts
  220.     pop    di    ; recover registers and segments
  221.     pop    si
  222.     pop    bx
  223.     pop    cx
  224.     pop    dx
  225.     pop    es
  226.     ret
  227. write_character endp
  228.  
  229.  
  230. code    ends
  231.     end
  232.