Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!news.uiowa.edu!uunet!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@actrix.gen.nz (David Empson) Subject: Re: Need Help with DOS 3.3 Launcher Launcher Message-ID: Organization: Actrix Information Exchange References: Date: Tue, 31 May 1994 14:03:44 GMT Lines: 87 In article , Ron "Asbestos" Dippold wrote: > > Now, on to the programming part, note the followups to csa2.programmer. There wasn't one, so I did it by hand. > Works beautifully, but there's one gotcha - Apparently the D3L author > (John? I don't have the docs here at the moment) never thought anyone > would be crazy enough to run it without booting GS/OS first, and that > everyone would use the finder. If you boot directly into ProDOS 8, > D3L tries to allocate memory for its CDA and fails with an out of > memory error. It works fine if you launch P8 from GS/OS, but FastBoot > breaks that assumption if you boot right into ProDOS 8. It isn't an out of memory error. It is an $0207 error returned by the MMStartUp call because MMStartUp is being called from a location which is not inside a valid handle (bank 0 memory isn't allocated if you boot ProDOS-8 directly). Here is some code derived from what I used in Quitter.System: clc xce rep #$30 ; 16-bit mode stz Bank0Hand ; Assume we didn't allocate a handle stz Bank0Hand+2 _TLStartUp pha _MMStartUp pla bcc GotID ; If MMStartUp returns an error, bank zero hasn't been allocated yet - the ; user probably cold booted into ProDOS-8 ; Get a new Application user ID and allocate some of bank zero for myself. ; This should be freed before exiting (along with the user ID) pha pea $1000 ; ID type = application _GetNewID plx bcs crash ; OUCH! pha pha ; Result space pea $0000 pea $B800 ; Size phx ; User ID pea $C002 ; Fixed address pea $0000 pea $0800 ; Address _NewHandle plx ply bcs crash ; Oh dear - major problem stx Bank0Hand sty Bank0Hand+2 pha _MMStartUp ; Try again... pla bcc GotID crash ; Do something ugly GotID ; Store your user ID somewhere In your case, you may as well leave bank 0 allocated and forget about the user ID (DOS 3.3 launcher will get it again when it calls MMStartUp). You may also wish to allocate bank 1, to protect it from other allocations (you wouldn't want the CDA there, for example, in case you used a DOS 3.3 program which used auxilary memory for something). > Simply calling the Init toolset function doesn't seem to be it. AAARRGHH! Don't _ever_ call any toolset BootInit function yourself, especially this one! (unless you like losing all allocated memory) :-) > I know it should be possible, because I've seen ProDOS 8 programs that > load CDAs, but I don't know if they're cheating or if they're actually > setting up the memory manager correctly. This is all explained on page 12-17 of Toolbox Ref Volume 1 (note in the MMStartUp call). -- David Empson dempson@actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand