Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #759 > unrolled thread

Good way to detect the current environment within ProDOS - launcher or BASIC?

Started byDavid Schmidt <schmidtd@my-deja.com>
First post2013-07-23 12:50 -0400
Last post2013-08-03 10:12 +0000
Articles 10 — 5 participants

Back to article view | Back to comp.sys.apple2.programmer


Contents

  Good way to detect the current environment within ProDOS - launcher or BASIC? David Schmidt <schmidtd@my-deja.com> - 2013-07-23 12:50 -0400
    Re: Good way to detect the current environment within ProDOS - launcher or BASIC? BLuRry <brendan.robert@gmail.com> - 2013-07-23 12:10 -0700
      Re: Good way to detect the current environment within ProDOS - launcher or BASIC? David Schmidt <schmidtd@my-deja.com> - 2013-07-23 16:37 -0400
        Re: Good way to detect the current environment within ProDOS - launcher or BASIC? BLuRry <brendan.robert@gmail.com> - 2013-07-23 17:29 -0700
          Re: Good way to detect the current environment within ProDOS - launcher or BASIC? Antoine Vignau <antoine.vignau@laposte.net> - 2013-07-24 11:16 -0700
            Re: Good way to detect the current environment within ProDOS - launcher or BASIC? BLuRry <brendan.robert@gmail.com> - 2013-07-24 12:17 -0700
    Re: Good way to detect the current environment within ProDOS - launcher or BASIC? gids.rs@sasktel.net - 2013-07-25 08:37 -0700
      Re: Good way to detect the current environment within ProDOS - launcher or BASIC? David Schmidt <schmidtd@my-deja.com> - 2013-07-25 12:57 -0400
        Re: Good way to detect the current environment within ProDOS - launcher or BASIC? gids.rs@sasktel.net - 2013-07-25 15:58 -0700
    Re: Good way to detect the current environment within ProDOS - launcher   or BASIC? ol.sc@web.de (Oliver Schmidt) - 2013-08-03 10:12 +0000

#759 — Good way to detect the current environment within ProDOS - launcher or BASIC?

FromDavid Schmidt <schmidtd@my-deja.com>
Date2013-07-23 12:50 -0400
SubjectGood way to detect the current environment within ProDOS - launcher or BASIC?
Message-ID<ksmbtj$lkb$1@dont-email.me>
I'd like to tell the current ProDOS environment underneath my program. 
I want to quit differently depending on being launched from BASIC (just 
RTS) or from the program launcher (ProDOS QUIT MLI call).  I toyed with 
checking zero page location $33 - recall that it will contain ']' or '*' 
if BASIC or the monitor were last active.  And the warmstart vector $3d0 
will contain a JMP to $BE00, and $BE00 will contain a JMP someplace else 
if BASIC is around.

But my problem is this: Boot into BASIC.SYSTEM, hit BYE, and then launch 
the subject program from the launcher.  All of the pointers I mentioned 
above indicate BASIC is available; but for my purposes, I want to detect 
that it's no longer "active."  Or, at least that's not where I should 
return to... I should return to the launcher.

How best to tell the difference?

[toc] | [next] | [standalone]


#760

FromBLuRry <brendan.robert@gmail.com>
Date2013-07-23 12:10 -0700
Message-ID<8cba16f5-22b4-4c97-88c5-8f61e6ccc42a@googlegroups.com>
In reply to#759
On Tuesday, July 23, 2013 11:50:48 AM UTC-5, schmidtd wrote:
> I'd like to tell the current ProDOS environment underneath my program. 
> 
> I want to quit differently depending on being launched from BASIC (just 
> 
> RTS) or from the program launcher (ProDOS QUIT MLI call).  I toyed with 
> 
> checking zero page location $33 - recall that it will contain ']' or '*' 
> 
> if BASIC or the monitor were last active.  And the warmstart vector $3d0 
> 
> will contain a JMP to $BE00, and $BE00 will contain a JMP someplace else 
> 
> if BASIC is around.
> 
> 
> 
> But my problem is this: Boot into BASIC.SYSTEM, hit BYE, and then launch 
> 
> the subject program from the launcher.  All of the pointers I mentioned 
> 
> above indicate BASIC is available; but for my purposes, I want to detect 
> 
> that it's no longer "active."  Or, at least that's not where I should 
> 
> return to... I should return to the launcher.
> 
> 
> 
> How best to tell the difference?

Does the reset vector reveal anything?

-B

[toc] | [prev] | [next] | [standalone]


#761

FromDavid Schmidt <schmidtd@my-deja.com>
Date2013-07-23 16:37 -0400
Message-ID<ksmp68$6i0$1@dont-email.me>
In reply to#760
On 7/23/2013 3:10 PM, BLuRry wrote:
> Does the reset vector reveal anything?

Ah, it reveals all!  $BE00 for BASIC, some other nonsense for not-BASIC. 
  Perfect - thanks!

[toc] | [prev] | [next] | [standalone]


#762

FromBLuRry <brendan.robert@gmail.com>
Date2013-07-23 17:29 -0700
Message-ID<def9d5b8-ae08-4e4f-80d6-c09e23d5358a@googlegroups.com>
In reply to#761
On Tuesday, July 23, 2013 3:37:18 PM UTC-5, schmidtd wrote:
> On 7/23/2013 3:10 PM, BLuRry wrote:
> 
> > Does the reset vector reveal anything?
> 
> 
> 
> Ah, it reveals all!  $BE00 for BASIC, some other nonsense for not-BASIC. 
> 
>   Perfect - thanks!

Least I can do!

-B

[toc] | [prev] | [next] | [standalone]


#769

FromAntoine Vignau <antoine.vignau@laposte.net>
Date2013-07-24 11:16 -0700
Message-ID<40460499-90fa-4233-893f-82bc74253536@googlegroups.com>
In reply to#762
I checked in source codes, real life examples, also read books and the RESET vector is definitively the thing to go for!

Very neat idea,
Antoine

[toc] | [prev] | [next] | [standalone]


#770

FromBLuRry <brendan.robert@gmail.com>
Date2013-07-24 12:17 -0700
Message-ID<35076db0-f7f0-4ac9-97ea-0364ed989afc@googlegroups.com>
In reply to#769
On Wednesday, July 24, 2013 1:16:32 PM UTC-5, Antoine Vignau wrote:
> I checked in source codes, real life examples, also read books and the RESET vector is definitively the thing to go for!
> 
> 
> 
> Very neat idea,
> 
> Antoine

For me it was a lucky guess -- but if you think about it, it is the closest thing to an application re-entry point as you'll get on a 6502 program.  I guess all those months kicking bugs out of the Jace CPU emulation counted for something.  :-D

-B

[toc] | [prev] | [next] | [standalone]


#773

Fromgids.rs@sasktel.net
Date2013-07-25 08:37 -0700
Message-ID<8f1090c4-a0b5-465a-be6c-c1c8eeaa4712@googlegroups.com>
In reply to#759
On Tuesday, July 23, 2013 10:50:48 AM UTC-6, schmidtd wrote:
> I'd like to tell the current ProDOS environment underneath my program. 
> I want to quit differently depending on being launched from BASIC (just 
> RTS) or from the program launcher (ProDOS QUIT MLI call).  I toyed with 
> checking zero page location $33 - recall that it will contain ']' or '*' 
> 
> if BASIC or the monitor were last active.  And the warmstart vector $3d0 
> will contain a JMP to $BE00, and $BE00 will contain a JMP someplace else 
> if BASIC is around.

> But my problem is this: Boot into BASIC.SYSTEM, hit BYE, and then launch 
> the subject program from the launcher.  All of the pointers I mentioned 
> above indicate BASIC is available; but for my purposes, I want to detect 
> that it's no longer "active."  Or, at least that's not where I should 
> return to... I should return to the launcher.

> How best to tell the difference?



I toyed with this a bit too.  But then I came to the realization that if you are launching a system program from BYE (since that is the only program it will launch), then you will always want to return to the BYE launcher.  Usually, if you launch a system program from basic, the system program disables basic.

That is why the MLI command BYE should pretty much be used in all system programs.

And a program to be launched from basic should be saved as a binary file and end in a JMP $3D0 to return to the applesoft prompt or a RTS to return to the basic program.

So, as you can see, I don't see any benefit to adding the reset vector check to any programs.

Rob

[toc] | [prev] | [next] | [standalone]


#774

FromDavid Schmidt <schmidtd@my-deja.com>
Date2013-07-25 12:57 -0400
Message-ID<ksrl16$5bl$1@dont-email.me>
In reply to#773
On 7/25/2013 11:37 AM, gids.rs@sasktel.net wrote:
> On Tuesday, July 23, 2013 10:50:48 AM UTC-6, schmidtd wrote:
>> [...] How best to tell the difference?
>
> I toyed with this a bit too.  But then I came to the realization that if you are launching a system program from BYE (since that is the only program it will launch), then you will always want to return to the BYE launcher.  Usually, if you launch a system program from basic, the system program disables basic.
>
> That is why the MLI command BYE should pretty much be used in all system programs.
>
> And a program to be launched from basic should be saved as a binary file and end in a JMP $3D0 to return to the applesoft prompt or a RTS to return to the basic program.
>
> So, as you can see, I don't see any benefit to adding the reset vector check to any programs.

Here's the benefit I see.  I have a binary program that users want to 
launch both ways: as a "BRUNnable" entity from BASIC, and as a SYS 
application from the launcher.  (Really, it's the installer for a device 
driver.)  So a BASIC user would find it jarring if they were to be 
bounced out of BASIC and into the laucher, as would happen with a QUIT 
call.  And someone expecting to run this from the launcher, then run a 
different interpreter would find it inconvenient to have to bounce back 
out of an unexpected BASIC invocation, as would happen with $3D0 or RTS. 
  (Well, RTS from a SYS application would crash... but that's another 
story.)

So, in this case - the dual personality is warranted.  If my app really 
were an interpreter expecting to replace BASIC, I would see the logic in 
the "always QUIT" approach.  But it's not.  It's really a helper that 
needs to have an affinity to either environment.

[toc] | [prev] | [next] | [standalone]


#776

Fromgids.rs@sasktel.net
Date2013-07-25 15:58 -0700
Message-ID<d3fd4d3d-753e-4d06-99f8-4e78ba82fbe3@googlegroups.com>
In reply to#774
> > So, as you can see, I don't see any benefit to adding the reset vector check to any programs.
> 
> 
> 
> Here's the benefit I see.  I have a binary program that users want to 
> 
> launch both ways: as a "BRUNnable" entity from BASIC, and as a SYS 
> 
> application from the launcher.  (Really, it's the installer for a device 
> 
> driver.)  So a BASIC user would find it jarring if they were to be 
> 
> bounced out of BASIC and into the laucher, as would happen with a QUIT 
> 
> call.  And someone expecting to run this from the launcher, then run a 
> 
> different interpreter would find it inconvenient to have to bounce back 
> 
> out of an unexpected BASIC invocation, as would happen with $3D0 or RTS. 
> 
>   (Well, RTS from a SYS application would crash... but that's another 
> 
> story.)
> 
> So, in this case - the dual personality is warranted.  If my app really 
> were an interpreter expecting to replace BASIC, I would see the logic in 
> the "always QUIT" approach.  But it's not.  It's really a helper that 
> needs to have an affinity to either environment.



Gotcha.  Your program can be used as either a binary program or system program depending on the user.

[toc] | [prev] | [next] | [standalone]


#784 — Re: Good way to detect the current environment within ProDOS - launcher or BASIC?

Fromol.sc@web.de (Oliver Schmidt)
Date2013-08-03 10:12 +0000
SubjectRe: Good way to detect the current environment within ProDOS - launcher or BASIC?
Message-ID<ktil1o$ur9$1@online.de>
In reply to#759
Hi David,

>I'd like to tell the current ProDOS environment underneath my program. 
>I want to quit differently depending on being launched from BASIC (just 
>RTS) or from the program launcher (ProDOS QUIT MLI call).

I didn't follow the reset vector approach pointed out by others.
Instead I look at the ProDOS system bit map:

https://github.com/oliverschmidt/cc65/blob/master/libsrc/apple2/crt0.s

Lines 143 to 146:

; Check ProDOS system bit map
lda     $BF6F           ; Protection for pages $B8 - $BF
cmp     #%00000001      ; Exactly system global page is protected
bne     basic

Regards,
Oliver

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.apple2.programmer


csiph-web