Jump to content
speccery

StrangeCart

Recommended Posts

1 hour ago, Tursi said:

You can write emulation in C, you know. ;) Or any other language.

 

 

:D sure you can. I was thinking about the Basic interpreter I’ve been working on. But yes, having a good C compiler would do it. In any case my use of C++ in these embedded system environments is very close to C.

  • Like 1

Share this post


Link to post
Share on other sites

I love your basic interpreter. I've always been a one command per line guy anyways.

You'll have to add a new keyword, probably something like speed.

I think the two places the interpreter might get in to the weeds are some of the more complex mathematical statements... including doing them all in matrix-100 for compatible output, and file I/O - since many of the device DSR don't even support the same commands.

  • Like 2

Share this post


Link to post
Share on other sites

Continued a bit with the basic interpreter development. I've been busy with RL, not much time for this project in the past week. I discovered I am still learning basic, as one of the test programs (Escape) breaks the interpreter. It's a very nice game by the way. Of course totally unplayable on the StrangeCart, the screen blinks and its game over, so need ingest a delay loop (or a new VSYNC command) somewhere. 

 

The problem I encountered is that the basic crashes after a few "game over" screens due to for-next stack becoming full. I think I made it 16-deep, so you can have 16 nested for-next loops. The reason for the stack filling up must be that the programs uses goto to break from the for-next loop. It later then enters this same loop again, when one starts a new game after "game over". At this point my basic interpreter allocates new space in the for-next stack, and eventually exhausts the stack. I believe the original TI basic unwinds the for-next stack when one uses goto to escape a loop before running it to completion. That's pretty interesting, and means I need to make "goto" much smarter than it is. It probably means that a goto can actually unwind any level of nesting of for-next loops. Reading the TI basic manual it multiple times states that each "for" must be matched with a "next". That of course makes sense, but it does appear that this is very rigid in TI basic. A for-next block effectively constitutes a scope, and goto out of the scope has semantic meaning. To live and learn.

  • Like 2

Share this post


Link to post
Share on other sites
13 hours ago, speccery said:

That's pretty interesting, and means I need to make "goto" much smarter than it is.

Well. I think this is the classic Entscheidungsproblem ... how to decide whether or not another GOTO will bring you back? When to discard the stack-entry? 

 

I would rather think that the same FOR-Loop resets the previous instance. This would also be easier to implement. What about when the FOR isn't the top of the stack? 

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, SteveB said:

Well. I think this is the classic Entscheidungsproblem ... how to decide whether or not another GOTO will bring you back? When to discard the stack-entry? 

 

I would rather think that the same FOR-Loop resets the previous instance. This would also be easier to implement. What about when the FOR isn't the top of the stack? 

Yes I think you’re probably right. It would appear that a for loop setup needs to traverse through the stack. If the variable is found already in the stack, it would be reset to the proper initial value and any other entries on top of it would be purged. Either way, it kinda sucks in my opinion. What I have now is a clean implementation, which obviously is wrong. Sigh.


a couple of test would be in order.

 

I have quite a few times during this implementation project been wanting to turn this into a compiler,  but I also want to have a pure interpreter first, so patience required. The amount of all kinds of error checks an interpreter needs to do is surprisingly big. Which makes me curious to understand how the BBC model B’s Basic was done, as it was very well done and fast. Or so I hear, have never tested one in person.

Share this post


Link to post
Share on other sites
4 hours ago, SteveB said:

Well. I think this is the classic Entscheidungsproblem ... how to decide whether or not another GOTO will bring you back? When to discard the stack-entry? 

 

I would rather think that the same FOR-Loop resets the previous instance. This would also be easier to implement. What about when the FOR isn't the top of the stack? 

I run all of my games in FOR-NEXT loops with break-outs when the games are over.  This prevents me from having to use GOTO in the loop and only either GOTO or THEN to exit.  My observation of TI BASIC and XB is that restarting the loop clears the stack of the old loop.

 

Generally, GOTOing out of a loop and back into it should be considered a no-no.  Programs expecting to temporarily leave a loop should use GOSUB, instead.

  • Like 3

Share this post


Link to post
Share on other sites
37 minutes ago, OLD CS1 said:

I run all of my games in FOR-NEXT loops with break-outs when the games are over.  This prevents me from having to use GOTO in the loop and only either GOTO or THEN to exit.  My observation of TI BASIC and XB is that restarting the loop clears the stack of the old loop.

 

Generally, GOTOing out of a loop and back into it should be considered a no-no.  Programs expecting to temporarily leave a loop should use GOSUB, instead.

Maybe that's the trap that could be installed in this new BASIC interpreter. 

GOTO inside a FOR/NEXT structure throws an error. ??

 

We have to start reigning-in the bad habits of BASIC programmers somehow.  :) 

(It's a joke. Don't kill me) 

 

  • Like 2

Share this post


Link to post
Share on other sites
On 10/7/2021 at 8:13 PM, TheBF said:

Maybe that's the trap that could be installed in this new BASIC interpreter. 

GOTO inside a FOR/NEXT structure throws an error. ??

I would say that GOTO outside of a FOR-NEXT loop would just invalidate that loop, then throw an error when they hit NEXT.  But that will break native behavior.  I just ran a test in which I GOTO out of a loop then back into it, and the loop completes as expected.  Next test I jump out of the loop then GOTO the start of the loop, which has been running now for several minutes having restarted the loop tens of times with no problems.

 

On 10/7/2021 at 8:13 PM, TheBF said:

We have to start reigning-in the bad habits of BASIC programmers somehow.  :)

(It's a joke. Don't kill me) 

Nah, BASIC does not necessarily encourage bad habits, but it does allow them.  At the same time, if we start cracking down on bad BASIC programmer behavior we run away from native behavior.

  • Like 2

Share this post


Link to post
Share on other sites

With this program I tested that indeed when the outer loop exists, the inner loop will also be purged even if it has not ran to completion. That at least makes sense.

 

IMG_4974.jpg

  • Like 3

Share this post


Link to post
Share on other sites
12 hours ago, speccery said:

With this program I tested that indeed when the outer loop exists, the inner loop will also be purged even if it has not ran to completion. That at least makes sense.

Were it not for the program flow, what you attempted would seem to be legal.  Obviously you cannot jump into a loop which has already completed, so the 300 to 305 flow would definitely be an error.  But something at 301, for instance, which by-passes 305 would seem to be valid.  Silly, but valid, and I do not expect BASIC to be smart enough for that.

 

Talk about bad habits, though... who would attempt such a mad exercise in real life?!

 

EDIT: never mind :)  I saw flow go from 215 to 305, rather than 300.  Now my brain is just making up shyte to prove something.

  • Like 3

Share this post


Link to post
Share on other sites

In the latest episode for RCR podcast #243 (Retro Computing Roundtable) the strangecart project was covered a bit. That was nice! I thought the comments were a bit different from what I expected, so I posted some feedback on their Facebook page, and that seems to be well received.

  • 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.
Note: Your post will require moderator approval before it will be visible.

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...