Newsgroups: comp.sys.apple2.programmer Path: news.uiowa.edu!chi-news.cic.net!news.uoregon.edu!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@atlantis.actrix.gen.nz (David Empson) Subject: Re: sys-turn Message-ID: Sender: news@actrix.gen.nz (News Administrator) Organization: Actrix - Internet Services Date: Fri, 19 Jan 1996 12:34:14 GMT References: <4dk8jj$fa9@natasha.rmii.com> X-Nntp-Posting-Host: atlantis.actrix.gen.nz Lines: 60 In article <4dk8jj$fa9@natasha.rmii.com>, Laine Houghton wrote: > I'm familiar with the prodos mli calls. What I couldn't figure from the > tech ref manual was how to have a sys file load and launch a program. Another SYS program, presumably? Running binary files directly is not a good idea unless you wrote them. BINs usually expect to work under BASIC.SYSTEM. There are two methods of launching another SYS file. First, if you are on a IIgs and have booted via GS/OS, you can use an extended version of the QUIT call, which allows you to specify the name of a program to launch. The QUIT parameter block for the extended call is as follows: quitPB DFB $04 ; parameter count DFB $EE ; subtype for extended call DA pathname ; pointer to pathname DFB $00 ; reserved DA $0000 ; reserved pathname STR '/FULL/OR/PARTIAL/PATHNAME' The launched program will quit to the GS/OS program which launched your program in the first place (or to whatever has been installed in the ProDOS quit code), i.e. the extended launch call simply passes control to another program, which replaces your one in the quit return chain. If you haven't booted via GS/OS, the parameters are ignored, and you will do a normal quit. To launch a SYS program directly, you need to perform the following steps: 1. If necessary, move any and all of your code out of the $2000-$BEFF area, and mark this area as unused in the ProDOS bitmap. 2. Use the MLI OPEN, READ and CLOSE calls to read the SYS file into memory starting at location $2000. You should probably use GET_FILE_INFO to check that it is a SYS file. You don't need to know the file size - just request a length of $9F00, which is the maximum size for a SYS file. 3. Mangle the reset vector, do any final tidying up (e.g. removing interrupt handlers), then JMP $2000. If you want to be able to "call" a SYS program and have it return to you when it quits, you will have to replace the Quit code at locations $D100-$D3FF in the alternate bank of the language card with your own code to reload your program. Preserving the original quit code is difficult, unless you are running on a IIgs, in which case it can be shuffled off into a handle outside banks 0 and 1. Otherwise, you might have to save it to disk. -- David Empson dempson@actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand