Visual bugs when scrolling graphical terminal

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Visual bugs when scrolling graphical terminal

Post by austanss »

I have attempted to implement terminal scroll, to no luck.

This is the output I get:
https://cdn.discordapp.com/attachments/ ... -07-37.mp4

This is the source file in question:
https://github.com/microNET-OS/microCOR ... rminal.cxx

I'm rather stumped at this point.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

Also, I previously posted a thread on this topic. I suffered some minor data loss, and I no longer have the scrolling code.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

OK I since fixed part of the issue, but now there is a different visual bug.

New footage: https://cdn.discordapp.com/attachments/ ... -08-48.mp4

I pushed my changes to github.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Visual bugs when scrolling graphical terminal

Post by eekee »

rizxt wrote:OK I since fixed part of the issue, but now there is a different visual bug.

New footage: https://cdn.discordapp.com/attachments/ ... -08-48.mp4
This looks like the display mode changes when it starts scrolling, possibly twice. Could the memcopy be accidentally writing into a VGA control register?

I remember a virtual desktop driver for the Atari ST which copied beyond the end of screen memory; probably an off-by-1 error. Since the screen was at the top of RAM and the ST halted with a bus error if you tried to write beyond the 4MB boundary, the virtual desktop driver worked just fine unless you'd upgraded your ST to 4MB.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

That doesn't seem to be the issue.

I changed the memcpy to be so short of it's goal it was visible on screen, and so far ahead of the start the colors were distorted, and it still yielded the same result.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

The buffer is proper, it works fine. I can save the screen to the buffer, and restore it properly.

When I scroll the screen via re-rendering the text buffer, it only works when writing directly to screen. If I try to write it to a buffer, that's when it gets hairy.

The only difference between my render_entry_at and render_entry_at_buffer is that one of them writes to the screen, and the other one writes to the buffer. Nothing else changes. The exact same. Meld re-affirms this.

I can't explain this UB.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Visual bugs when scrolling graphical terminal

Post by neon »

Hi,

Looks like memory corruption to me. What you should be doing is single stepping the assembly. Do not make assumptions about the code nor its running environment when it does not function as expected. Since execution does not appear to end, it may also be stack related or running garbage code. I'd bet the function doesn't return to where you expect it does.

With that said, I took this from your render_entry_at. If your code often has code like this, you are corrupting the stack in more then one location. The last index here is not 64 and the first index is 0. Check your code and be very careful when filling buffers or you can get unexpected behavior.

Code: Select all

uint8_t bits[64];
for (uint8_t i = 1; i <= 64; i++) {
	bits[i] = util::get_bit(font_selector, i);
}
"it works fine" -- I said that about a file written a few years ago and just yesterday while testing an unrelated program is when I find a bug while viewing its object code. Oh, the code worked fine -- but it still had the bug and I wonder how it worked in the first place. You may be surprised how often claiming something is correct turns out not to be true. Working code is often times not Correct code.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

I set breakpoints in the code but they are just being passed.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Visual bugs when scrolling graphical terminal

Post by neon »

Hi,

The code posted above would write one past the end of the array (thus corrupting the byte allocated after, if any.) Since the array is allocated on the stack, this can effect other variables. Please let us know that you have corrected this and all other instances of this bug as it can result in undefined behavior. Array indices start at 0 and end at last_element - 1.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

Yes, I fixed that particular issue. I do believe this resolves an intermittent bug with garbage pixels in my character fonts, but that bug is unrelated.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Visual bugs when scrolling graphical terminal

Post by austanss »

OK, issue resolved.

I was applying fixes, but my build system was not updating the kernel.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
Post Reply