home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / FIXFAN.ZIP / FIXFANSI.ASM next >
Encoding:
Assembly Source File  |  1988-02-20  |  3.1 KB  |  115 lines

  1. ; Copyright 1988 John P. Nelson (all rights reserved)
  2. ;    The binary of this program may be used for any purpose whatever,
  3. ;    the source may be distributed freely, but must retain this copyright
  4. ;    notice.  The techniques used in this program may be copied and used
  5. ;    freely without retaining the copyright notice.
  6. ;
  7. ; Change history:
  8. ; fixfansi.asm    20-Feb-88 13:50 John added copyright notice before distribution
  9. ;        04-Feb-88 16:29 John Author
  10. ;
  11. ; fixfansi is a terminate-and-stay-resident program that fixes an
  12. ; incompatibility between turbo pascal 4.0 and FANSI-CONSOLE versions
  13. ; 1.11 and 1.15.  Version 2.00 of FANSI-CONSOLE does not exhibit this
  14. ; problem, but has different problems with the CRT unit (and
  15. ; "directvideo").  It is unknown whether versions of FANSI-CONSOLE before
  16. ; 1.11P require this fix.  As I do not have an EGA, I have not tested
  17. ; this program for EGA operation.  It works fine with mono (hercules)
  18. ; and CGA displays.
  19. ;
  20. ; This program intercepts the video interrupt (int 10h), and
  21. ; handles function 0 (change video mode) by calling the original
  22. ; int 10 vector, then fixing BIOS ram location 40:4c.  For some
  23. ; unknown reason, FANSI always stores the value 00A0H at this location,
  24. ; where TURBO (and the IBM rom bios listing) is expecting the length
  25. ; of the current video page.  Note that fixfansi does NOT fix mode
  26. ; changes caused by sending escape sequences to the console since
  27. ; FANSI-CONSOLE bypasses INT 10H in this case.  fixfansi stores the
  28. ; value 4000H (16K), if (and only if) it finds 00A0 at this location
  29. ; after the mode change, so fixfansi is safe to use even if
  30. ; FANSI-CONSOLE is not resident.  The value 4000H is used because
  31. ; this is the largest possible page size, (hires graphics mode), and
  32. ; because TURBO seems to calculate the correct end-of-screen anyway.
  33. ; FANSI does not seem to use this location at all.
  34.  
  35. _text    segment    para public 'CODE'
  36.     assume    cs:_text,ds:_text,ss:_text
  37.     org    100h
  38.  
  39. fixfansi    proc    far
  40.     jmp    begin
  41. fixfansi    endp
  42.  
  43. oldvec    dw    0,0
  44. ;
  45.     assume    nothing
  46.     assume    cs:_text
  47. newvec    proc    far
  48.     cmp    ah,0
  49.     jz    fix
  50.     jmp    dword ptr oldvec
  51. fix:
  52.     pushf        ; popped by reti at oldvec!
  53.     call    dword ptr oldvec
  54.     push    es
  55.     push    ax
  56.     mov    ax,40h
  57.     mov    es,ax
  58.     mov    ax,es:[4ch]
  59.     cmp    ax,00a0h    ; fansi always stores a0,00 for some reason
  60.     jnz    cleanup
  61.     mov    ax,4000h    ; insert 00,40 (16K) instead
  62.     mov    es:[4ch],ax
  63. cleanup:
  64.     pop    ax
  65.     pop    es
  66.     iret
  67.  
  68. newvec    endp
  69.  
  70.     assume    cs:_text,ds:_text,ss:_text
  71. begin    proc    near
  72. ;    save old vector
  73.     mov    ah,35h
  74.     mov    al,10h
  75.     int    21h
  76.     mov    oldvec,bx
  77.     mov    oldvec[2],es
  78.  
  79. ;    store new replacement vector
  80.     mov    ah,25h
  81.     mov    al,10h
  82.     lea    dx,newvec
  83.     int    21h
  84.  
  85. ;    free up environment block
  86.     mov    es,ds:[2ch]
  87.     mov    ah,49h
  88.     int    21h
  89.  
  90. ;    make page length fix immediately without switching modes
  91.     mov    ax,40h
  92.     mov    es,ax
  93.     mov    ax,es:[4ch]
  94.     cmp    ax,00a0h    ; fansi always leaves a0,00 for some reason
  95.     jnz    gores
  96.     mov    ax,4000h    ; insert 00,40 (16K) instead
  97.     mov    es:[4ch],ax
  98.  
  99. ;    terminate & stay resident
  100. gores:
  101.     mov    ah,31h
  102.     mov    al,0
  103.     lea    dx,begin
  104.     shr    dx,1
  105.     shr    dx,1
  106.     shr    dx,1
  107.     shr    dx,1
  108.     inc    dx
  109.     int    21h
  110. ;    notreached
  111. begin    endp
  112.  
  113. _text   ends
  114.     end fixfansi
  115.