home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Games / JST / InstallWizard / source / loadseg.asm < prev    next >
Encoding:
Assembly Source File  |  2001-03-19  |  1.1 KB  |  68 lines

  1.     cnop    0,4
  2.  
  3. ; loads an executable by calling OSEmu LoadSeg()
  4. ;
  5. ; < A0: name of the executable
  6. ; > A1: start address (do a JSR (a1) to start the program)
  7. ; > A0: pointers on arguments
  8. ; > D0: argument string length
  9. ;
  10. ; ** no checks are done there so be careful **
  11.  
  12. LoadExecutable:
  13.     movem.l    A2-A6/D1-D7,-(A7)
  14.     move.l    A0,-(A7)
  15.     MOVE.L    $4.W,A6            ;OPEN DOSLIB FOR USE (THE EMU
  16.     MOVEQ.L    #0,D0            ;PROVIDES THE FUNCTIONS)
  17.     LEA    dosname(PC),A1
  18.     JSRLIB    OpenLibrary
  19.     RELOC_MOVEL    D0,dosbase
  20.     MOVE.L    D0,A6
  21.     move.l    (A7)+,A0
  22.  
  23.     MOVE.L    A0,D1
  24.     JSRLIB    LoadSeg
  25.     TST.L    D0
  26.     BEQ.B    .exit
  27.     RELOC_MOVEL    D0,loaderseg
  28.  
  29.     LSL.L    #2,D0
  30.     MOVE.L    D0,A1
  31.     ADDQ.L    #4,A1
  32.  
  33.     lea    progargs(pc),A0
  34.     move.l    A0,D0
  35.     JSRGEN    StrlenAsm    ; arguments length
  36.  
  37.     JSRGEN    FlushCachesHard
  38.     movem.l    (A7)+,A2-A6/D1-D7
  39.     rts
  40.  
  41. .exit
  42.     JSRGEN    InGameExit
  43.  
  44. ; unloads previously loaded executable
  45.  
  46. UnloadExecutable:
  47.     STORE_REGS
  48.     move.l    dosbase(pc),A6
  49.     move.l    loaderseg(pc),D1
  50.     JSRLIB    UnLoadSeg
  51.     RESTORE_REGS
  52.     rts
  53.  
  54. FileErr:
  55.     Mac_printf    "** Cannot find file ...."
  56.     JMPABS    CloseAll
  57.  
  58. loaderseg:
  59.     dc.l    0
  60. dosbase:
  61.     dc.l    0
  62. progargs:
  63.     ; your arguments here (ex: dc.b "/f data1")
  64.     dc.b    10,0        ; linefeed + null termination
  65. dosname:
  66.     dc.b    "dos.library",0
  67.  
  68.