home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / turbopas / turbopat.lbr / TPATCH1.Z80 next >
Text File  |  1988-04-06  |  2KB  |  76 lines

  1. ; TURBO PASCAL VERSION 3.0 PATCH BY JAY SAGE, 04/22/85
  2.  
  3. ; This code patches TURBO Pascal Version 3.0 so that it will find the
  4. ; error message overlay file TURBO.MSG in a different user area (given
  5. ; by the equate TUSER below).  The patch is appended to the standard code
  6. ; but relocates itself higher in memory so that it is not overwritten by
  7. ; the error message text as it is loaded.  The call at address 2232h is
  8. ; the one made if the question about including the error messages was answered
  9. ; in the affirmative.  The call is replaced by a conditional call to this
  10. ; patch code.  The patch code in turn calls the original code, but only after
  11. ; the user number has been switched to the special value.  After the MSG file
  12. ; is loaded, the patch code re-logs the original user area.  This patch does
  13. ; nothing about the logged drive, since Turbo itself tries a number of drives.
  14. ; My directory TURBO: is on drive A and is always found.  If this patch fails
  15. ; to find the right drive for you, try adding code to log in the desired
  16. ; drive in the same way.  Remember that the relocated code has no absolute
  17. ; addresses so that it can simply be copied to its new location.
  18.  
  19.  
  20. tbdos    equ    7265h        ;Turbo's BDOS call (protects IX, IY)
  21. userf    equ    20h        ;BDOS get/set user number function
  22. tuser    equ    2        ;user number of TURBO: directory
  23. dest    equ    9000h        ;destination for relocated section (above
  24.                 ;..area used for messages)
  25.  
  26. ; --------------------
  27.  
  28.     org    2232h        ;original code to patch
  29.  
  30.     call    nz,patch
  31.  
  32. ; --------------------
  33.  
  34.     org    7980h        ;new code to append to original code
  35.  
  36. patch:
  37.     push    hl        ;save registers
  38.     push    de
  39.     push    bc
  40.  
  41.         ;relocate patch code to safe area
  42.  
  43.     ld    hl,pbeg        ;source of code to move
  44.     ld    de,dest        ;destination
  45.     ld    bc,pend-pbeg    ;length of section to move
  46.     ldir            ;move it
  47.     jp    dest        ;continue with moved code
  48.  
  49.         ;code to be relocated
  50.  
  51. pbeg:
  52.     ld    c,userf        ;get current user #
  53.     ld    e,0ffh
  54.     call    tbdos
  55.     push    af        ;save user number
  56.  
  57.     ld    c,userf        ;log in Turbo user area
  58.     ld    e,tuser
  59.     call    tbdos
  60.  
  61.     call    2da4h        ;call Turbo code for loading TURBO.MSG
  62.  
  63.     pop    af        ;restore user number
  64.     ld    e,a
  65.     ld    c,userf
  66.     call    tbdos
  67.  
  68.     pop    bc        ;restore registers
  69.     pop    de
  70.     pop    hl
  71.     ret
  72.  
  73. pend    equ    $        ;mark end of code for relocation
  74.  
  75.     end
  76.