Last week, while programming a small BASIC 10 program, I was annoyed that it is so complicated to implement several case distinctions. If, for example, based on the value of a variable, I have over 50 possible branches, then BASIC 10 becomes really complex, because you can only use fix line number with GOTO or GOSUB.
That annoyed me so much that I sat down at the ROM at the weekend and dig me into the GOSUB/GOTO code.
As a result of this weekend, I can publish a patch that extends the GOSUB and GOTO commands of the BASIC 10, so that they no longer only accept fix line numbers as parameters, but also formulas and variables.
So it is very easy to program branches depending on a value of a variable.
The patch work with the latest C65 ROM 911210 and the 911001. The easiest way to patch your ROM is to use M65Connect from the MEGA Filehost. It is available there on the homepage for Windows, Linux and Mac.
I will describe the procedure with Linux, but with Windows and Mac it's nearly the same.
1.) If not still installed, load M65Connect and unzip it.
2.) Load the attached patch and unzip it too.
3.) Start M65Connect and select the "Abort" button after start if you don't be connected to your DevKit/MEGA65 or if you don't have one.
4.) Select "File - Apply ROM patch file"
5.) Select your ROM file you want to patch in "Source ROM file" and the unzipped attached patch file in "ROM patch file"
6.) Save the patched file with "Save patched ROM as..." to your prefered folder
7.) Rename your patched ROM file to "MEGA65.ROM" for use it with your MEGA65/DevKit/Nexys board. For using it with xc65 or xmega65 emulator from LGB-Z or hernandp you can select it from SDcard menu or rename it "c65-system" in the xemu ROM folder.
That's it!
Please be aware:
If the result of a GOSUB/GOTO parameter isn't a valid line number then you still get an error as it is known with normal GOTO/GOSUB.
The ROM changes apply only GOSUB and GOTO. The use of ON ... GOTO .... and ON ... GOSUB ... is another code part in the C65 ROM. I think it's makes less sense to modify them too, because the selection of the GOTO/GOSUB line will be done by the variable after ON.
The attached patch only modify the GOSUB/GOTO code of the C65 ROM. No other changes are made with this patch. But you can use the patch also with a still patched 911210 or 911001 if you like.
The patched ROM is still 100% compatible to existing BASIC 10 programs which uses GOTO or GOSUB. But if you use the flexible parameter with GOSUB or GOTO in your program they will cause errors while trying to run it on a unpatched ROM. It will only work with a unpatched ROM if you only use fix line number at GOTO/GOSUB.
The patch works with the 911210 and 911001 C65 ROM. It will not work with the new MEGA65 ROMs (92....) with this patch. If the MEGA team is interested, the changes can of course also be implemented there.
I have tested the patch yesterday and find no errors. Please send a feedback if you will find any errors!
Now if you are interested, have fun with flexible GOSUB/GOTO parameters!