home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Games / JST / sources / src / loaders / SensibleSoccerCD32 / senssochd.asm < prev   
Encoding:
Assembly Source File  |  2001-03-19  |  2.5 KB  |  147 lines

  1. ; *** Imperium Hard Disk Loader V2.0
  2. ; *** Written by Jean-François Fabre 1999
  3.  
  4.  
  5.     include    "syslibs.i"
  6.     include    "jst.i"
  7.  
  8.     HD_PARAMS    "",0,0
  9.  
  10. loader:
  11.  
  12.     Mac_printf    "Sensible Soccer CD32 HD Loader V2.0"
  13.     Mac_printf    "Coded by Jean-François Fabre © 1999"
  14.  
  15.     JSRABS    DisableChipmemGap    ; 2megs of chipmem will be allocated (os swap)
  16.     JSRABS    UseHarryOSEmu        ; loads OSEmu.400 and installs it
  17.  
  18.     lea    LOADERFILE(pc),A1
  19.     move.l    A1,D0
  20.     JSRABS    TestFile
  21.     tst.l    d0
  22.     bne    FileErr            ; file 'loader' not found
  23.  
  24.     lea    SOCV1FILE(pc),A1
  25.     move.l    A1,D0
  26.     JSRABS    TestFile
  27.     tst.l    d0
  28.     bne    TryV2            ; file 'soccer' not found. V2?
  29.  
  30.     lea    SOCV1FILE(pc),A1
  31.     move.l    A1,D0
  32.     JSRABS    GetFileLength
  33.     cmp.l    #1000,D0        ; check if size if below 1000 bytes
  34.     bcc    ExeFound        ; not a script: it's V1
  35.  
  36. TryV2
  37.  
  38.     JSRGEN    GetUserFlags
  39.     btst    #AFB_NTSC,D0
  40.     bne    .boot_ntsc        ; user specified NTSC
  41.  
  42.     lea    SOCPALFILE(pc),A1
  43.     move.l    A1,D0
  44.     JSRABS    TestFile
  45.     tst.l    d0
  46.     beq    ExeFound
  47.     bra    FileErr            ; SOC.PAL not found: error
  48.  
  49. .boot_ntsc
  50.     lea    SOCNTSCFILE(pc),A1
  51.     move.l    A1,D0
  52.     JSRABS    TestFile
  53.     tst.l    d0
  54.     bne    FileErr            ; SOC.NTS not found: error
  55.  
  56.  
  57. ExeFound:
  58.     RELOC_MOVEL    A1,SOCCERNAME    ; this will be the name of the exe
  59.  
  60.     JSRABS    LoadFiles        ; load program files
  61.  
  62.     moveq.l    #0,D0
  63.     move.l    #CACRF_CopyBack,D1
  64.     JSRABS    Degrade            ; disables copyback cache
  65.  
  66.     GO_SUPERVISOR
  67.     SAVE_OSDATA    $200000,#$5D    ; 2MB saved, quitkey = numerical '*'
  68.  
  69.     ; boot stuff and patch
  70.     ; thanks to Harry for this piece of code 
  71.  
  72.     MOVE.L    $4.W,A6            ;OPEN DOSLIB FOR USE (THE EMU
  73.     MOVEQ.L    #0,D0            ;PROVIDES THE FUNCTIONS)
  74.     LEA    DOSNAM(PC),A1
  75.     JSRLIB    OpenLibrary(A6)
  76.     LEA.L    DOSP(PC),a4
  77.     MOVE.L    d0,(a4)
  78.     MOVE.L    D0,A6
  79.  
  80.     LEA.L    LOADERFILE(PC),A0
  81.     MOVE.L    A0,D1
  82.     JSRLIB    LoadSeg
  83.     RELOC_MOVEL    D0,loader_seg
  84.  
  85.     LSL.L    #2,D0
  86.     MOVE.L    D0,A1
  87.     ADDQ.L    #4,A1
  88.  
  89.     SUB.L    A0,A0
  90.     MOVEQ.L    #0,D0        ; no pointer on argumentline
  91.  
  92.     JSRGEN    FlushCachesHard
  93.  
  94.     jsr    (A1)
  95.  
  96.     move.l    DOSP(pc),A6
  97.     move.l    loader_seg(pc),D1
  98.     JSRLIB    UnLoadSeg
  99.  
  100.     move.l    DOSP(pc),A6
  101.     move.L    SOCCERNAME(PC),A0
  102.     MOVE.L    A0,D1
  103.     JSRLIB    LoadSeg
  104.  
  105.     LSL.L    #2,D0
  106.     MOVE.L    D0,A1
  107.     ADDQ.L    #4,A1
  108.  
  109.     SUB.L    A0,A0
  110.     MOVEQ.L    #0,D0        ; no pointer on argumentline
  111.  
  112.     JSRGEN    FlushCachesHard
  113.  
  114.     jsr    (A1)        ; go!
  115.  
  116.     JSRGEN    InGameExit
  117.  
  118.     ; error message
  119.  
  120. FileErr:
  121.     Mac_printf    "** File '",v
  122.     JSRABS    Display
  123.     Mac_printf    "' missing!"
  124.     JSRABS    CloseAll
  125.  
  126.     ; data
  127.  
  128. loader_seg:
  129.     dc.l    0
  130. DOSP:
  131.     dc.l    0
  132. SOCCERNAME:
  133.     dc.l    0    ; will reference the name of the executable actually used
  134. DOSNAM:
  135.     dc.b    "dos.library",0
  136.  
  137.     ; executable filenames
  138.  
  139. LOADERFILE:
  140.     dc.b    "loader",0
  141. SOCV1FILE:
  142.     dc.b    "soccer",0
  143. SOCPALFILE:
  144.     dc.b    "SOC.PAL",0
  145. SOCNTSCFILE:
  146.     dc.b    "SOC.NTSC",0
  147.