It is unfortunate that all of your beta-testers are also programmers!
I've been thinking about how to slim it down some more, and today I coded it.
The target was the screen handling, as that was messy. I wasn't going to mess with the TCP code - that works, and I've been squeezing it for a long time already. But the screen handling code looked like a crawling horror.
In the original code I:
- Let the C runtime put new strings up on the console. (This means I couldn't put new strings up if the backscroll feature was active.)
- Saved and restored the current screen whenever backscroll was invoked
- Had two different buffer areas - one for the backscroll area, and one for the current screen that wasn't in the backscroll area yet
You can see where this is heading ... two different save areas is more complex than it needs to be.
In the current test code I unified the buffers. All screen updates go to one buffer first, which contains all of the data. Then after all screen updates are applied (usually at the end of a line, or in some cases multiple lines) I draw the screen from the buffer back to the video memory.
This has some advantages:
- The code is much simpler now.
- I can speed things up by doing two or three lines of updates at a time before drawing, instead of one line at a time. This helps when you get those floods of lines from the IRC server.
- I can change the program flow so that I can add to the buffer in the background. (With the old code I couldn't add anything without having the screen available because it was using the c runtime to draw chars on the screen.)
That last feature will let me process incoming data in the background while the backscroll buffer is being viewed, which is a big plus - no more missed 'pings' and no more TCP/IP buffers in danger of being filled. As a result, I should be able to cut my TCP/IP buffers down quite a bit with no fear of lost data.
The new code so far (with equivalent function) is just over 1400 bytes smaller, which is about 2% of the code size. Expect a new version sometime this week. With the snow completely eliminated. I won't be lazy this time.