scotws / TaliForth2

A Subroutine Threaded Code (STC) ANS-like Forth for the 65c02
Other
86 stars 22 forks source link

xt_words doesn't respect max line length correctly #270

Open wkjagt opened 1 year ago

wkjagt commented 1 year ago

When using words on an 80 column terminal, many lines will be slightly longer than 80 characters, see screenshot below.

image

I've been staring at xt_words for a while but I can't see anything wrong with how it determines when to put a CR. But somehow it does manage to output lines well over 80 characters. I looked in headers.asm but the word lengths in there seem correct. I also directly hardcoded cmp #79 in the loop that loops over the words, but that changes nothing, so it doesn't compare to an accidental longer line length either.

I'm going to keep staring at this a bit more, but I thought you might know about this issue, or the cause of it.

wkjagt commented 1 year ago

I found what is causing this. This is setting the counter back to 0 while it already has the next word in memory that it's about to print, so it needs to take that word's length into consideration. So instead of lda #0, this should be lda 0,x, which holds the length of the current word. And then an additional inc to take the printed space into account, same as just above. I'll see if I can put up a pull request.

image
SamCoVT commented 1 year ago

Hi @wkjagt. Thank you for opening an issue and your sleuthing work to find the root cause. That's a good catch. We have two master branches (for two different assemblers - we're moving to 64tass for conditional assembly support), but you can issue a pull request for either master branch and I'll apply the patch to the other branch. You're likely on the "master" branch using the Ophis assembler. Scot hasn't been super active recently so it may be a bit before it gets pulled into this repository.

wkjagt commented 1 year ago

👋 @SamCoVT Thanks for the message! Yeah, I'm on master, using Ophis. I just put up a PR here: https://github.com/scotws/TaliForth2/pull/271. This change fixes it for me. I hope the PR is complete. I saw that some other changes were also generated when running make, in docs I think. I didn't commit those. Not sure if I should have.

This is an awesome project by the way. I am using it on my homebrew 6502. I have 80 column text output to a screen, and a custom keyboard, so this TaliForth works really well with that, and really makes it feel like a standalone computer with a fun OS and completely independent from a connection to a laptop 😄