bgri / m100LE

A Wordle-like game for the vintage Tandy (Radio Shack) Model 100
11 stars 1 forks source link

Maybe tighten code #28

Open hackerb9 opened 2 years ago

hackerb9 commented 2 years ago

After adding in the DATE$ portability, the tokenized BASIC version takes up over 13KB of space. Not a big deal since the smallest machine we're likely to see is 24KB, but it could be improved.

Note that 13KB is the version with comments that could be removed for some space savings during tokenization. It might be a good idea to come up with a convention for lines with comments that should not be removed because they are targets for GOTO or GOSUB and lines which can be completely removed. Perhaps something like this

10 REM Lines that start with REM should never be removed
11 ' But comments using apostrophe mean the line isn't necessary
12 ' for the program to run correctly. 

It would be good to go through the code again, with an eye towards minimizing it while still keeping it understandable.

bgri commented 2 years ago

It would be good to go through the code again, with an eye towards minimizing it while still keeping it understandable.

Oh, for sure. My free time is growing a bit, and I did want to look at the overall structure as well as reducing it a bit. Good idea re: a convention. I like your suggestion.

Also, removing the comments for the uncommented version was a pain last time, so anything that makes it easier (script that nukes all lines beginning with ' ) would be great :)

bgri commented 2 years ago

Looks like this may have to happen sooner rather than later. I can't load the latest version of the .do into the VirtualT emulator. Nor will it load into my 102. I'll start working on that to get the file size down. Feel free to ping me if I'm taking it too far :)

bgri commented 2 years ago

Hacky version done. Main code untouched. DecommentFodder folder contains a stripped version and the spreadsheet that did the deed.

Line 6015 played havoc with it as I was using the single quote as a delimiter, which meant the code got stretched across a number of cells with the single quote removed.

It runs in the emulator. And we now have an ugly process to shrink the code so it loads and runs in the emulator and hardware, I hope. Haven't tested the hardware yet and dinner awaits!

bgri commented 2 years ago

But this does not solve the code-cleanup issue. Just gets it small enough to fit into my stuff. Would be cool if there was an IDE that would not save comments when saving out a file. Probably was (back in the day) but I can't seem to find anything modern. Closest I've come is Geany and treat the filetype as FreeBasic.

hackerb9 commented 2 years ago

But this does not solve the code-cleanup issue. Just gets it small enough to fit into my stuff. Would be cool if there was an IDE that would not save comments when saving out a file. Probably was (back in the day) but I can't seem to find anything modern. Closest I've come is Geany and treat the filetype as FreeBasic.

Nice work with the spreadsheet!

When I send the .DO file to my Tandy 200 over a serial port, it tokenizes each line as it loads to save space. You may want to do something similar. On the Tandy, I do this:

LOAD "COM:98N1ENN"

That will load into BASIC whatever comes in on the serial port at 19,200 baud. Then on the connected PC (runnig GNU/Linux), I just dump the .DO file over the serial port, followed by a Control-Z (end-of-file marker):

(cat M100LEl.DO; echo $'\cZ'; read -p "Hit Enter when done") > /dev/ttyUSB0

Details

However, this is a bit awkward, so it may make sense to automatically generate tokenized BASIC versions. I had started writing a C program to do that, but got waylaid before it was debugged.

hackerb9 commented 2 years ago

By the way, for fun, I try develop on my Tandy 200, so I'd like this program to be smaller even with comments. Although 24K (the max size of a Tandy 200's RAM bank) is enough that I can load the tokenized program, including all comments, I can no longer EDIT the whole file. I can only EDIT small chunks, which means it is difficult to do a search through the whole code to see if, for example, a variable name has already been used elsewhere.

bgri commented 2 years ago

'morning! Just back from camping and catching up :)

When I send the .DO file to my Tandy 200 over a serial port, it tokenizes each line as it loads to save space. You may want to do something similar.

Great process! I love that each line is tokenized as it's read. I'll have to check that out -- I'm taking note of it. I code in Geany on my Mac (and occasionally windows -- cross-platform for the win!). I've become used to 'modern' screen sizes and get frustrated with the limitation of 8 lines. Your use of a 200 to do this has inspired me to look for something similar.

I've recently picked up a period-correct printer so once I get around to cleaning-testing it, it'll help with the programming workflow.

And, to stay on topic, I'll be looking for a few things that could be optimized after I get reorganized from the trip.

hackerb9 commented 2 years ago

Great process! I love that each line is tokenized as it's read. I'll have to check that out -- I'm taking note of it. I

I've created a shell script, adjunct/sendtomodelt, that encapsulates the process of sending the program a line at a time. Theoretically, it should work on any UNIX system. I've only tested it on Debian GNU/Linux. It may run fine on MacOS and/or WSL, Windows Subsystem for Linux,... or the script might require some tweaking.

[P.S. That printer looks fantastic. It's small and looks to have surprisingly good resolution. I have an old TRS-80 DMP-100 printer and I haven't bothered to get new ink for it because the output is fairly awful.]