Jump to content
OLD CS1

Detecting 32k in Extended BASIC

Recommended Posts

Another post indicates that checking the value at -31952 (>8330, I believe) will indicate the absence of 32k RAM if the return is 55.

 

However, I have now tested this on real hardware and in Classic99 and I get 255 for 32k RAM present but that changes to a different value once a program is loaded.  Classic99 returned 55 then 29 after a program loaded (32k disabled,) while one console returns 63 with no 32k attached.

 

I assume there is an accepted "standard" for detecting 32k from Extended BASIC -- remembering that I can neither LOAD values into 32k space nor CALL INIT without incurring a fatal error.

 

I tried catching a CALL INIT error with ON ERROR, but the RETURN sends execution right back to the bad statement.

 

I also tried some other fancy shenanigans to no avail.

1 ON ERROR 100 :: ON BREAK NEXT
2 CALL INIT
3 PRINT "SUCCESS"
4 STOP
100 CALL ERR(A,B,C,D):: PRINT A;B;C;D :: BREAK 2 :: RETURN

Arrrr Extended BASIC... she be a harsh mistress.

  • Like 2

Share this post


Link to post
Share on other sites
Posted (edited)

CALL PEEK(-31860,A,B)  CALL PEEK(-31868,A,B)

Should be 255,231 with memory expansion; 0,0 if no memory

CALL INIT

CALL LOAD(-31868,0,0,0,0) turns off memory expansion as far as XB is concerned. Programs will run from VDP memory, but you can still load assembly support!

 

(Edit) It is -31868. You really only need to look at the first byte. If A=0 then no memory expansion.

Edited by senior_falcon
  • Like 1

Share this post


Link to post
Share on other sites

@senior_falcon I will give it a try, thank you.

 

This also means I have to release an update to my last game.  ::sigh::

  • Like 2

Share this post


Link to post
Share on other sites

@atrax27407 Tah.  This is where I found the 55 value I was using, but I see I missed other possibilities in it.

 

"-31952,X IF x=55 then memory expansion is off else it is on."

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, TheBF said:

Man, where was this document in 1985? :)

 

Scattered around various user group newsletters.  I recall a few example programs in ours.  But it appears the only two PEEKs in the document regarding 32k detection are incorrect.

  • Like 1

Share this post


Link to post
Share on other sites

I think there was an extensive list in "The Smart Programmer" by Miller's Graphics and a bunch of them appeared in MICROpendium as well. The one I posted is a copy of several lists that were thrown together into a single list.

 

  • Like 1

Share this post


Link to post
Share on other sites

I think this works the way you wanted your example program to work?  

 

1 ON ERROR 100
2 CALL INIT
3 PRINT "SUCCESS"
4 STOP
100 CALL ERR(A,B,C,D)::PRINT A;B;C;D::RETURN NEXT

On real hardware, without 32K, this prints the 4 error numbers, then prints "SUCCESS" and stops.  With 32K, it only prints SUCCESS. 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, Casey said:

RETURN NEXT

Sunnuva gun!  I completely forgot about that construct.  Yes, that would work as well to set a flag for the 32k present or not (the assumption being that CALL INIT will return a * SYNTAX ERROR.)

  • Like 2

Share this post


Link to post
Share on other sites

Again:

 

10 CALL PEEK(-31868,X)::IF X=0 THEN PRINT "NO 32K" ELSE PRINT "32K"

 

This will always work and is about as simple as it can be.

 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...