home *** CD-ROM | disk | FTP | other *** search
/ Crazy Collection 1 / CC-01.iso / GAMES_1 / GPU / INCPATCH.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-02  |  6.6 KB  |  144 lines

  1. ;-----------------------------------------------------------------
  2. ;Patch for Grand Prix Unlimited
  3. ;See the Crack.nfo file for information pertaining to this program
  4. ;-----------------------------------------------------------------
  5.  
  6. ;-----------------------------------------------------------------
  7. ;Define equates used in the program
  8. ;-----------------------------------------------------------------
  9. cr            EQU            0Dh                 ;carriage return
  10. lf            EQU            0Ah                 ;line feed
  11.  
  12. code          SEGMENT
  13.               ASSUME         CS:code,DS:code
  14.               ORG            100h
  15.  
  16. strt:
  17.               MOV            DX,OFFSET welcome
  18.               MOV            AH,09h
  19.               INT            21h
  20.  
  21. ;-----------------------------------------------------------------
  22. ;Now, we will open the file to be written to.
  23. ;-----------------------------------------------------------------
  24.               MOV            AL,1                ;Write only operation
  25.               MOV            DX,OFFSET fname     ;move fname to DX
  26.               MOV            AH,3Dh              ;open file
  27.               INT            21h
  28.               JNC            open_ok             ;jump if no errors
  29.               PUSH           AX                  ;push error code onto stack
  30.               JMP            error               ;jump to error routine
  31.  
  32. open_ok:
  33. ;-----------------------------------------------------------------
  34. ;Now we have to move the file pointer to the proper location in
  35. ;The program.
  36. ;-----------------------------------------------------------------
  37.               MOV            BX,AX               ;move file handle to bx
  38.               MOV            AL,00               ;move pointer from beginning
  39.               MOV            CX,0000h            ;m.s. offset in hex
  40.               MOV            DX,9A3Dh            ;l.s. offset in hex
  41.               MOV            AH,42h              ;move file pointer
  42.               INT            21h
  43.               JNC            move_ok             ;jump if no errors
  44.               PUSH           AX                  ;push error code onto stack
  45.               JMP            error               ;jump to error routine
  46.  
  47. move_ok:
  48. ;-----------------------------------------------------------------
  49. ;Now we will write the new bytes to the program
  50. ;BX holds file handle
  51. ;-----------------------------------------------------------------
  52.               MOV            CX,1                ;number of bytes to write
  53.               MOV            DX,OFFSET databuff  ;move data to DX
  54.               MOV            AH,40h              ;write to file
  55.               INT            21h
  56.               JNC            write_ok            ;jump if no errors
  57.               PUSH           AX                  ;push error onto stack
  58.               JMP            error               ;jump to error routine
  59.  
  60. write_ok:
  61. ;-----------------------------------------------------------------
  62. ;Now we have to close the file before we leave
  63. ;BX holds file handle
  64. ;-----------------------------------------------------------------
  65.               MOV            AH,3Eh              ;close file
  66.               INT            21h
  67.               JNC            exit                ;jump if no errors & exit
  68.               PUSH           AX                  ;push error onto stack
  69.               JMP            error               ;jump to error routine
  70.  
  71. error:
  72. ;-----------------------------------------------------------------
  73. ;Parse the error code returned from the system and display
  74. ;The appropriate error message
  75. ;-----------------------------------------------------------------
  76.               POP            AX                  ;return error code
  77.  
  78.               CMP            AX,1
  79.               JE             code1
  80.               CMP            AX,2
  81.               JE             code2
  82.               CMP            AX,3
  83.               JE             code3
  84.               CMP            AX,4
  85.               JE             code4
  86.               CMP            AX,5
  87.               JE             code5
  88.               CMP            AX,6
  89.               JE             code6
  90.  
  91.  
  92.               MOV            DX,OFFSET nocode    ;no matching error code
  93.               JMP            print_error
  94. code1:        MOV            DX,OFFSET error1    ;invalid function
  95.               JMP            print_error
  96. code2:        MOV            DX,OFFSET error2    ;file not found
  97.               JMP            print_error
  98. code3:        MOV            DX,OFFSET error3    ;path not found
  99.               JMP            print_error
  100. code4:        MOV            DX,OFFSET error4    ;no handle available
  101.               JMP            print_error
  102. code5:        MOV            DX,OFFSET error5    ;access denied
  103.               JMP            print_error
  104. code6:        MOV            DX,OFFSET error6    ;handle invalid
  105.               JMP            print_error
  106.  
  107. ;-----------------------------------------------------------------
  108. ;Display error code to user
  109. ;-----------------------------------------------------------------
  110. print_error:
  111.               MOV            AH,09h              ;display stirng
  112.               INT            21h
  113.  
  114. ;-----------------------------------------------------------------
  115. ;Now we are done so let's close up shop
  116. ;-----------------------------------------------------------------
  117. exit:
  118.               MOV            DX,OFFSET goodbye
  119.               MOV            AH,09h
  120.               INT            21h
  121.  
  122.               MOV            AX,04C00h           ;terminate program
  123.               INT            21h
  124.  
  125. ;-----------------------------------------------------------------
  126. ;Data area
  127. ;-----------------------------------------------------------------
  128. fname         DB             'GPU.EXE',0     ;define file name
  129. welcome       DB             'Generic Patch Maker v1.0',cr,lf
  130.               DB             'Designed by Jake Pickett',cr,lf,lf
  131.               DB             'Please wait while Grand Prix Unlimited is '
  132.               DB             'being patched.',cr,lf,'$'
  133. goodbye       DB             'Thank you for choosing INC!',cr,lf,'$'
  134. nocode        DB             '<<Unkown Error Code>>',cr,lf,'$'
  135. error1        DB             '<<Invalid Function>>',cr,lf,'$'
  136. error2        DB             '<<File Not Found>>',cr,lf,'$'
  137. error3        DB             '<<Path Not Found>>',cr,lf,'$'
  138. error4        DB             '<<No Handle Available>>',cr,lf,'$'
  139. error5        DB             '<<Access Denied>>',cr,lf,'$'
  140. error6        DB             '<<Handle Invalid Or Not Open>>',cr,lf,'$'
  141. databuff      DW             0EBh               ;bytes to write out
  142.  
  143. code          ENDS
  144.               END            strt