home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1997 #5 / amigaacscoverdisc1997-051997.i / games / installers / sotb3 / src / sotb3hddev / sotb3hd.asm < prev   
Assembly Source File  |  1997-07-23  |  5KB  |  353 lines

  1.  
  2. ; *** Shadow Of The Beast 3 Hard Disk Loader V1.1a
  3. ; *** Written by Jean-François Fabre
  4.  
  5.     include    "/lib/libs.i"
  6.     include    "/lib/macros.i"
  7.     include    "/lib/refs.i"
  8.  
  9. _loader:
  10.     move.l    D0,trainer
  11.  
  12.     Mac_printf    "Shadow Of The Beast 3 HD Loader V1.1b"
  13.     Mac_printf    "Programmed by Jean-François Fabre © 1997"
  14.  
  15.     tst.l    trainer
  16.     beq    trskip$
  17.  
  18. ;    NEWLINE
  19. ;    Mac_printf    "Trainer mode activated"
  20. trskip$
  21.     move.l    #mainname,D0
  22.     JSRABS    TestFile
  23.     tst.l    D0
  24.     bne    MainErr
  25.  
  26.     ; ** test if a file from disk 2 is here (to see if disk 2 has been installed)
  27.  
  28.     move.l    #f40name,D0
  29.     JSRABS    TestFile
  30.     tst.l    D0
  31.     bne    MainErr
  32.  
  33.     move.l    #5000,D0
  34.     JSRABS    LoadSmallFiles
  35.  
  36. ;    bsr    MemoryConfig
  37.  
  38.     JSRABS    TransfRoutines
  39.  
  40.     moveq.l    #0,D0
  41.     move.l    #CACRF_CopyBack,D1
  42.     JSRABS    Degrade
  43.  
  44. ;    WAIT_LMB
  45.  
  46.     GO_SUPERVISOR
  47.     SAVE_OSDATA    $80000
  48.  
  49.     MOVEA.L    #$00080000,A7
  50.     MOVEA.L    #$00DFF000,A6
  51.     MOVE    #$7FFF,dmacon(A6)
  52.     MOVE    #$7FFF,intena(A6)
  53.     MOVE    #$7FFF,intreq(A6)
  54.  
  55.     move.l    ExtBase,D0
  56.     MOVE.L    ExtSize,D1
  57.     MOVE.l    ExtFlag,D2
  58.  
  59.     MOVE.L    D0,$4.W        ; extension base pointer
  60.     MOVE.L    D1,$8.W        ; memory extension size
  61.  
  62.     GETUSRADDR    BootGame
  63.     move.l    D0,A0
  64.     jmp    (A0)
  65.  
  66.  
  67. MemoryConfig:
  68.     move.l    #$100000,D0
  69.     JSRABS    AllocExtMem
  70.     move.l    D0,ExtBase
  71.     beq    not1MB$
  72.  
  73.     move.l    #$100000,ExtSize
  74.     move.l    #$0F0,ExtFlag
  75.     bra    suite$
  76. not1MB$
  77.     move.l    #$80000,D0
  78.     JSRABS    AllocExtMem
  79.     move.l    D0,ExtBase
  80.     beq    not512Fast$
  81.  
  82.     move.l    #$80000,ExtSize
  83.     move.l    #$00F,ExtFlag
  84.     bra    suite$
  85.  
  86. not512Fast$:
  87.     ; *** only the 512K chipmem used
  88.     clr.l    ExtSize
  89.     clr.l    ExtFlag
  90.     clr.l    ExtBase
  91.  
  92. suite$
  93.     rts
  94.  
  95.  
  96.  
  97.     ; ** in case the user tries to run the game without having installed
  98.     ; ** the game properly
  99.  
  100. MainErr:
  101.     Mac_printf    "** File ''main'' missing or disk 2 not installed."
  102.     Mac_printf    "   Please install the game properly and try again !!"
  103.     JMPABS    CloseAll
  104.  
  105. MemErr:
  106.     Mac_printf    "** Not enough memory to run Shadow Of The Beast III"
  107.     JMPABS    CloseAll
  108.  
  109. FileNotFound:
  110.     Mac_printf    "** Run-time error: a file is missing."
  111.     Mac_printf    "   Please install the game properly and try again !!"
  112.     JSRABS    WaitReturn
  113.     rts
  114.  
  115. UnrecogErr:
  116.     Mac_printf    "** Version of game not supported"
  117.     Mac_printf    "   Please contact the author!"
  118.     JSRABS    WaitReturn
  119.     rts
  120.  
  121.  
  122. _UserPatchRoutines:
  123.  
  124. BootGame:
  125.     ; *** read the file 'main'
  126.  
  127.     lea    mainname(pc),A0
  128.     lea    $70000,A1    
  129.     moveq.l    #0,D0
  130.     moveq.l    #-1,D1
  131.     JSRGEN    ReadFile
  132.  
  133.     bsr    PatchMain
  134.     GETUSRADDR    PatchLoader1
  135.     move.l    D0,$BC.W
  136.  
  137.     ; *** flush the caches (just in case)
  138.  
  139.     JSRGEN    FlushCachesHard
  140.  
  141.     ; *** and start the dance
  142.  
  143.     nop
  144.     nop
  145.     JMP    $7001A
  146.     nop
  147.     nop
  148.  
  149.  
  150. PatchMain:
  151.     lea    version(pc),A4
  152.  
  153.     cmp.l    #$01E02049,$70100
  154.     bne    not_pal$
  155.  
  156.     ; *** removes a check for NTSC
  157.     ; *** (both versions are country-protected)
  158.  
  159.     move.b    #$60,$7008A
  160.  
  161.     move.l    #1,(A4)
  162.     bra    verok$
  163.  
  164. not_pal$    
  165.     cmp.l    #$C7806100,$70100
  166.     bne    not_ntsc$
  167.  
  168.     ; *** NTSC version
  169.  
  170.     ; *** removes a check for PAL
  171.     ; *** (both versions are country-protected)
  172.  
  173.     move.w    #$4E71,$7008A
  174.  
  175.     move.l    #2,(A4)
  176.     bra    verok$
  177.  
  178.     ; *** unrecognized version: quit
  179.  
  180. not_ntsc$
  181.     move.l    #UnrecogErr,D0
  182.     JSRGEN    SetExitRoutine
  183.     JSRGEN    InGameExit
  184.     bra    not_pal$
  185. verok$
  186.     ; *** patch the file
  187.  
  188.     lea    $70684,A0
  189.     cmp.l    #2,(A4)
  190.     bne    1$
  191.  
  192.     ; *** NTSC version is shifted by 4 bytes
  193.  
  194.     lea    $4(A0),A0
  195. 1$
  196.     GETUSRADDR    DiskRoutine
  197.     move.w    #$4EF9,(A0)+
  198.     move.l    D0,(A0)
  199.  
  200.     lea    $702C4,A0
  201.     cmp.l    #2,(A4)
  202.     bne    2$
  203.  
  204.     ; *** NTSC version is shifted by 4 bytes
  205.  
  206.     lea    $4(A0),A0
  207. 2$
  208.  
  209.     move.w    #$4E4F,(A0)
  210.     rts
  211.  
  212. PatchLoader1:
  213.     STORE_REGS
  214.  
  215.     ; *** patch the disk routine
  216.     
  217.     PATCHUSRJMP    $6B4D2,DiskRoutine
  218.  
  219.     ; *** remove a mask of the memory zone
  220.     ; *** which overrides some of the memory
  221.  
  222.     move.w    #$6024,$4AFC.W
  223.     
  224.     ; *** installs the quit patch (menu)
  225.  
  226.     PATCHUSRJSR    $7BEE.W,kbint2
  227.  
  228.     ; *** installs the quit patch (in game)
  229.  
  230.     PATCHUSRJSR    $7D10.W,kbint
  231.     move.w    #$4E71,$7D16
  232.  
  233.     ; *** activates the original cheat keys
  234.  
  235.     move.w    #$4E71,$7D2C.W
  236.  
  237.     ; *** and starts the main program
  238.  
  239.     JSRGEN    GoECS
  240.     JSRGEN    FlushCachesHard
  241.  
  242.     RESTORE_REGS
  243.     jmp    $256.W
  244.  
  245. DiskRoutine:
  246.     cmp.b    #5,D1
  247.     beq    DR_DirRead
  248.     cmp.b    #0,D1
  249.     beq    DR_FileRead
  250.  
  251.     moveq.l    #0,D0
  252.     bra    DR_End
  253.  
  254.     ; *** load the file
  255.  
  256. DR_FileRead:
  257.     moveq.l    #0,D0
  258.     moveq.l    #-1,D1
  259.  
  260.     JSRGEN    ReadFile
  261.     tst.l    D0
  262.     bmi    DR_Error    ; not found : fatal error : quit
  263.  
  264.     move.l    D0,D1
  265.     moveq.l    #0,D0
  266.     bra    DR_End
  267.  
  268. ; *** read directory
  269.  
  270. DR_DirRead:
  271.     moveq.l    #0,D0
  272.     moveq.l    #0,D1
  273. DR_End:
  274.     MOVEM.L    (A7)+,D2-D7/A0-A6
  275.     RTS
  276.  
  277. ; *** other commands, still not supported
  278.  
  279. DR_Other:
  280.     cmp.w    #1,D1
  281.     beq    DR_FileWrite
  282. DR_Error:
  283.     move.l    #FileNotFound,D0
  284.     JSRGEN    SetExitRoutine
  285.     JSRGEN    InGameExit
  286.     bra    DR_Error
  287.  
  288. ; *** write file (not used in SOTB3)
  289. ; D0 holds the length to write but we ignore it
  290. ; because we write only the scores
  291.  
  292. DR_FileWrite:
  293.     moveq.l    #-1,D0
  294.     moveq.l    #0,D1
  295.     bra    DR_End
  296.  
  297.  
  298. kbint2:
  299.     move.b    $BFEC01,D0
  300.     move.l    D0,-(sp)
  301.     ror.b    #1,D0
  302.     not.b    D0
  303.     cmp.b    #$54,D0    ; raw keycode for F5
  304.     bne    noquit$
  305.     JSRGEN    InGameExit
  306. noquit$
  307.     move.l    (sp)+,D0
  308.     tst.b    $BFEC01
  309.     rts
  310.  
  311. kbint:
  312.     cmp.b    #$57,D0    ; their code for F5
  313.     bne    noquit$
  314.     JSRGEN    InGameExit
  315. noquit$
  316.     cmp.b    #$75,D0    ; original game
  317.     bne    nothing$
  318.     jmp    $7E58.W
  319. nothing$    
  320.     rts
  321.  
  322.  
  323. LocalPatchExcept:
  324.     move.l    $8.W,-(sp)    ; used by the game to store data
  325.     JSRGEN    PatchExceptions
  326.     move.l    (sp)+,$8.W
  327.     rts
  328.  
  329.  
  330.  
  331. trainer:
  332.     dc.l    0
  333. _user_pbuffer:
  334.     dc.l    0
  335. _general_pbuffer:
  336.     dc.l    0
  337. ExtBase:
  338.     dc.l    0
  339. ExtSize:
  340.     dc.l    0
  341. ExtFlag:
  342.     dc.l    0
  343. version:
  344.     dc.l    0
  345. mainname:
  346.     dc.b    "main",0
  347. f40name:
  348.     dc.b    "f40",0
  349.     cnop    0,4
  350. _EndUserPatchRoutines:
  351.  
  352.     HD_PARAMS    "","CON:20/20/350/150/Shadow Of The Beast 3 HD Loader",0,0
  353.