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

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