Page 1 of 3
Strange letter displays before string [ACTUALLY SOLVED]
Posted: Tue Jan 10, 2017 4:46 pm
by DixiumOS
I made my own simple print string routine, hosted on
https://github.com/NunoLava1998/DixiumOS-1 (First commit)
However, when i try to run this in QEMU, a phantom monochrome S appears before my text:
How would i fix this unexpected character?
Re: Strange letter displays before string
Posted: Tue Jan 10, 2017 4:51 pm
by bzt
DixiumOS wrote:How would i fix this unexpected character?
Debug your code and find the instruction that puts it there. Then modify your source to avoid that.
Re: Strange letter displays before string
Posted: Tue Jan 10, 2017 5:05 pm
by Octacone
I don't like the way your code works. You should have two separate functions: one for printing characters and one for printing characters at a certain position. Your clear screen functions is really really bad, the most unoptimized function ever. Tomorrow I am going to make a GitHub account and edit your repository a bit and help you with your OS + commentary included. Try printing that string without calling your clear screen function.
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 1:21 am
by DixiumOS
octacone wrote:I don't like the way your code works. You should have two separate functions: one for printing characters and one for printing characters at a certain position. Your clear screen functions is really really bad, the most unoptimized function ever. Tomorrow I am going to make a GitHub account and edit your repository a bit and help you with your OS + commentary included. Try printing that string without calling your clear screen function.
writechar is different than writestring:
Write char writes a character at the specified foreground, background, x position, y position.
Write string uses write char to write a string using the same technique as used in the Bare Bones tutorial. Both can print characters at a certain position, but one writes strings and another writes characters.
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 1:51 am
by iansjack
You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.
All the same, an improvement on your previous efforts.
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 1:53 am
by DixiumOS
iansjack wrote:You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.
All the same, an improvement on your previous efforts.
Thank you.
I also moved the string to 40, 10 and it displayed fine but that S was still there.
I'll make a terminal_init that clears the screen and that S.
EDIT: It doesn't clear. Must be a problem in my putchar.
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:04 am
by hannah
DixiumOS wrote:iansjack wrote:You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.
All the same, an improvement on your previous efforts.
Thank you.
I also moved the string to 40, 10 and it displayed fine but that S was still there.
I'll make a terminal_init that clears the screen and that S.
EDIT: It doesn't clear. Must be a problem in my putchar.
Push my pull request
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:07 am
by iansjack
bzt wrote:
Debug your code and find the instruction that puts it there. Then modify your source to avoid that.
None of the OP's code puts the character there. More to the point - look at the code and see why it doesn't write to that location.
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:29 am
by DixiumOS
hannah wrote:DixiumOS wrote:iansjack wrote:You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.
All the same, an improvement on your previous efforts.
Thank you.
I also moved the string to 40, 10 and it displayed fine but that S was still there.
I'll make a terminal_init that clears the screen and that S.
EDIT: It doesn't clear. Must be a problem in my putchar.
Push my pull request
Pushed it. I think i'm unpushing it (code is wrong, various things are undefined and many things are defined for no reason and then never used, and the types in 2 functions don't even exist.)
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:34 am
by Octocontrabass
Hmm.
Any particular reason you created a new account, NunoLava1998?
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:41 am
by DixiumOS
Octocontrabass wrote:Hmm.
Any particular reason you created a new account, NunoLava1998?
I want to start over again.
And good news, i got it working (i had to change (y * 80 + x) to (y * 80 + x - 1)).
Got it working, thanks everybody!
https://github.com/NunoLava1998/DixiumO ... inal/tty.c
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:43 am
by Octocontrabass
DixiumOS wrote:And good news, i got it working (i had to change (y * 80 + x) to (y * 80 + x - 1)).
You didn't fix it, you just added a second bug that hides the first bug.
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:46 am
by DixiumOS
Octocontrabass wrote:DixiumOS wrote:And good news, i got it working (i had to change (y * 80 + x) to (y * 80 + x - 1)).
You didn't fix it, you just added a second bug that hides the first bug.
So... what bug?
It works perfectly fine on QEMU and seems logical:
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:48 am
by Octocontrabass
Re: Strange letter displays before string
Posted: Wed Jan 11, 2017 2:54 am
by DixiumOS
That isn't a bug. If i didn't add that line, only the last char would display in the specified x and y like i used putchar.
Besides, here's another image demonstrating it works: