OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:06 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Cursor shifts after enabling it on real hardware
PostPosted: Fri Feb 17, 2023 11:00 am 
Offline
Member
Member

Joined: Mon Jul 30, 2018 2:58 am
Posts: 45
Hello!

My problem is that cursor in my OS gets a bit crazy after calling this funtion:

Code:
void VGA_enable_cursor()
{
   int cursor_start = 13;
   int cursor_end = 14;

   outb(VGA.IO_Port_RegisterIndex, 0x0A);
   outb(VGA.IO_Port_DataRegister, (inb(0x3D5) & 0xC0) | cursor_start);

   outb(VGA.IO_Port_RegisterIndex, 0x0B);
   outb(VGA.IO_Port_DataRegister, (inb(0x3E0) & 0xE0) | cursor_end);
}


After I call this function the cursor moves by 4 spaces to the right and when it's in the first row it takes up 4 spaces. It only happens on a real hardware but works just fine on Quemu and Bochs emulators.

Is it something I can fix?


Top
 Profile  
 
 Post subject: Re: Cursor shifts after enabling it on real hardware
PostPosted: Fri Feb 17, 2023 11:37 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Well, assuming your code is correct (which I don't know because I never programmed the VGA), I would think that the problem is that your video card is not a VGA, and its VGA emulation does not support what you want to do here.

Personally, I can only tell you to stick to VBE/GOP. Get a framebuffer going, render everything to it. Then you can make the cursor any shape you should want it to have. You can even change the font.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Cursor shifts after enabling it on real hardware
PostPosted: Fri Feb 17, 2023 11:44 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Matt1223 wrote:
Code:
inb(0x3E0)

That's not a VGA register.


Top
 Profile  
 
 Post subject: Re: Cursor shifts after enabling it on real hardware
PostPosted: Fri Feb 17, 2023 11:45 am 
Offline
Member
Member

Joined: Sat Feb 04, 2012 5:03 pm
Posts: 111
Matt1223 wrote:
After I call this function the cursor moves by 4 spaces to the right and when it's in the first row it takes up 4 spaces. It only happens on a real hardware but works just fine on Quemu and Bochs emulators.

Is it something I can fix?

I'm not sure registers 0x0A and 0x0B are what you want.

http://www.scs.stanford.edu/12au-cs140/ ... reg.htm#0E seems to indicate you want registers 0x0E and 0x0F in the CRTC registers. Can you check if your VGA.IO_Port_RegisterIndex is the base + 4 (so if the VGA is located at 0x3d0 your IO_PORT_RegisterIndex should be 0x3d4) -- assuming you agree and want to access registers 0x0E and 0x0F of course.

(Looks like Octocontrabass spotted this issue too.)


Top
 Profile  
 
 Post subject: Re: Cursor shifts after enabling it on real hardware
PostPosted: Fri Feb 17, 2023 11:47 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
sounds wrote:
I'm not sure registers 0x0A and 0x0B are what you want.

It seems correct to me. This code is just supposed to make the cursor visible, not change its location.


Top
 Profile  
 
 Post subject: Re: Cursor shifts after enabling it on real hardware
PostPosted: Fri Feb 17, 2023 11:57 am 
Offline
Member
Member

Joined: Mon Jul 30, 2018 2:58 am
Posts: 45
Octocontrabass wrote:
Matt1223 wrote:
Code:
inb(0x3E0)

That's not a VGA register.


Right! I don't know why I used this register #-o . I corrected it and everything works fine. Thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 76 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group