Sign in to follow this  
  • entries
    292
  • comments
    557
  • views
    153568

GOSUB without RETURN

Sign in to follow this  
TANSTAAFL

175 views

I have had a lot of fun removing the cobwebs from Hammurabi thus far, but I've taken it about as far as it can go. At this point, it screams "Yahoo! Widget", "Flash" or "Open Lazlo", which means a complete paradigm shift anyway, i.e. it'll have to be completely redone. And that's okay... Hammurabi is not the most complex of games.




So, on to the next forgotten BASIC text based game:

http://www.atariarchives.org/adventure/chapter15.php

I decided on a slightly different tactic this time...

For one, I decided to go with C++ right off the bat, using std::cout, and std::string.

But this time, I decided to write functions to replace the various BASIC commands. It isn't quite exact, but I did get to write a templated print function and input function. I got to simulate the read/data mechanism of BASIC (fortunately, this game only has numeric DATA statements, not numbers and strings mixed.

And so I'm going along quite swimmingly. As the game runs, it foists the main loop onto a subroutine with a GOSUB, which is all well and good, until I notice the part where the subroutine checks for death.... there is a GOTO, and it leaps outside of the subroutine.

Now, I've been approximating subroutines and GOSUBs with functions, and now I've got a GOTO in a function, and where it needs to get to in another function.

Of course, this really speaks poorly of the writer of the original code. Even by the standards of the time, one should not have a GOSUB without a RETURN.

And that just goes to show that back in the day(ca. 1983), as it is now, they let just any old person write a book.

My solution to the problem at hand? I'm going to put the common code into a separate function, put a label in the subroutine, and call that function from both the functions that need it to run.

The bar is really really low for code quality during a port like this.

Sign in to follow this  


2 Comments


Recommended Comments

MMM, wrong direction. What you need is a BASIC interpreter done in Flash or OpenLaszlo so that you can just paste that code in and run it.

Of course, that Coco emulator you were working on would work too.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now