Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TVoutPrint.cpp #140

Merged
merged 1 commit into from
Nov 17, 2022
Merged

Update TVoutPrint.cpp #140

merged 1 commit into from
Nov 17, 2022

Conversation

davidadkins1
Copy link
Contributor

TVout::write does not allow the last column to be printed.

if (cursor_x >= (display.hres*8 - pgm_read_byte(font))) {

should be

if (cursor_x > (display.hres*8 - pgm_read_byte(font))) {

TVout::write does not allow the last column to be printed.

if (cursor_x >= (display.hres*8 - pgm_read_byte(font))) {

should be

if (cursor_x > (display.hres*8 - pgm_read_byte(font))) {
@Avamander
Copy link
Owner

I'm not sure it's correct.

Trying to print characters when cursor_x is equal to horizontal resolution will mean the printed letter will exceed the horizontal resolution (display.hres*8 - pgm_read_byte(font))).

The cursor is at the end of the screen, next letter would end up beyond it, would it not?

@davidadkins1
Copy link
Contributor Author

davidadkins1 commented Nov 16, 2022

I have verified this in my project. I cannot write the last column because of the >=
My testing indicates that cursor_x is the left-most pixel of the character that is to be rendered in X.
pgm_read_byte(font) returns the width of the font in pixels.

given:
resolution is 128x96
font is 4x6
cursor_x is 0 to 127
the last valid cursor_x for a 4x6 font is 124
124.125.126.127 (the last column)

where:

display.hres = 16
pgm_read_byte(font) = 4
cursor_x = 124

display.hres*8 - pgm_read_byte(font) = 128 - 4 = 124
cursor_x >= 124 so the character is printed on the next line. This is a "bug."

where:

display.hres = 16
pgm_read_byte(font) = 4
cursor_x = 125

display.hres*8 - pgm_read_byte(font) = 128 - 4 = 124
cursor_x > 124 so character is printed on the next line.

where:

display.hres = 16
pgm_read_byte(font) = 4
cursor_x = 128 (actually this is invalid, but since you asked)

display.hres*8 - pgm_read_byte(font) = 128 - 4 = 124
cursor_x > 124 so character is printed on the next line.

TVout::inc_txtline() appears to properly handle scrolling on the bottom line.

@davidadkins1
Copy link
Contributor Author

davidadkins1 commented Nov 17, 2022

Here is some sample code and two pictures made with and without the write bug. Notice 128 is divisible by the 4-bit wide font. The 6x8 font does not exhibit the problem unless the x resolution is divisible by 6. For example, 126x96 with the 6x8 font has the problem.

#include <TVout.h>
#include <fontALL.h>

TVout TV;

void setup()
{
TV.begin(NTSC);
TV.select_font(font4x6);
TV.clear_screen();

for (char i = 32; i < 127; i++)
{
TV.write(i);
}
}

void loop()
{
}

PXL_20221117_203653368

PXL_20221117_203458208

@Avamander Avamander merged commit 2d4b053 into Avamander:master Nov 17, 2022
@Avamander
Copy link
Owner

Thank you for the convincing argumentation and the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants