Need help with setting VGA 265-color mode

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
Aaron
Posts: 7
Joined: Sun May 15, 2011 2:43 pm

Need help with setting VGA 265-color mode

Post by Aaron »

Hi! I'm in need of help setting the video mode from 80x25 text mode to VGA 265-color mode. I get this in my terminal window from compiling kernel.c:

Code: Select all

kernel.c: In function 'setmode':
kernel.c:80:13: error: storage size of 'regs' isn't known
Here is my setmode void:

Code: Select all

void setmode(byte mode)
{
   union REGS regs;
   regs.h.ah = 0x00;
   regs.h.al = mode;
   int86(0x0C,&regs,&regs);
}
And if you were wondering, my putpixel void:

Code: Select all

void putpixel(int x, int y, byte color)
{
   unsigned char *VGA = (unsigned char *)0xA0000000L; //for some reason, byte was not working. So I just put unsigned char since that was byte is.
   unsigned short offset;
   offset = 320*y + x;
   VGA[offset] = color;
}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Need help with setting VGA 265-color mode

Post by Combuster »

The compiler is not just giving an error, it's giving an error description. Since you read the forum rules and therefore comply to the required knowledge and smart questions rules, diagnosing the problem should be trivial.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Need help with setting VGA 265-color mode

Post by Gigasoft »

Your "voids". :lol: Are you serious? You've just started to learn programming, and you thought an operating system would be a great exercise to start with (if you can find the time between becoming a famous rockstar, disbanding the Colombian mafia and revolutionizing the oil industry, of course)?

"VGA" has to be declared as a far pointer by the way.
Aaron
Posts: 7
Joined: Sun May 15, 2011 2:43 pm

Re: Need help with setting VGA 265-color mode

Post by Aaron »

Gigasoft wrote:You've just started to learn programming
I'm not new to programming at all. Try not to assume. :/
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Need help with setting VGA 265-color mode

Post by Love4Boobies »

Aaron wrote:
Gigasoft wrote:You've just started to learn programming
I'm not new to programming at all. Try not to assume. :/
If you aren't even new at it, then it's a problem. Try finding something you're good at---no one is good at everything. I'm not trying to be rude, it's just friendly advice.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Need help with setting VGA 265-color mode

Post by Gigasoft »

And, notice that "265-color mode" is mentioned twice :P
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Need help with setting VGA 265-color mode

Post by Love4Boobies »

Heh, I didn't even notice that :lol:
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Aaron
Posts: 7
Joined: Sun May 15, 2011 2:43 pm

Re: Need help with setting VGA 265-color mode

Post by Aaron »

Love4Boobies wrote: Try finding something you're good at
I've spent a lot of time over the past few years dedicated to programming. So I guess if I'm no good at it, I've wasted many hours of life. :?
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: Need help with setting VGA 265-color mode

Post by zity »

Well, let me give you a few more hints.

- Your socalled voids are called functions.
- Where and how did you define the union REGS?
- Have you implemented the function int86?
- And as gigasoft mentions, your VGA pointer is not declared corret.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Need help with setting VGA 265-color mode

Post by Combuster »

Aaron wrote:
Love4Boobies wrote: Try finding something you're good at
I've spent a lot of time over the past few years dedicated to programming. So I guess if I'm no good at it, I've wasted many hours of life. :?
Compare it to teaching someone in a wheelchair to do pole-vaulting. In due time he knows the techniques and can spot the differences between good athletes and the lesser ones, but he still won't be able to pull off the stunt himself.

That said, yours truly spent 8 years teaching himself programming before trying on the subject of OS development. In that regard taking a course is so much more efficient. At any rate your current level of both C and toolchain knowledge is insufficient to be here.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: Need help with setting VGA 265-color mode

Post by DavidCooper »

Aaron wrote:I've spent a lot of time over the past few years dedicated to programming. So I guess if I'm no good at it, I've wasted many hours of life. :?
Have you written anything that works? If so, there's probably nothing wrong with your ability - it's just that you have to learn an awful lot of crap about horrible programming environments and overly-complicated programming languages before you can do everything you want. Learn from your mistakes here and keep going, at least for a while. Read other people's code when they post it here and see how they do things, because that will give you clues about whether your code is close to being up to the mark or miles away from it, and if it is miles away you can learn a lot from them and become a better programmer without exposing your mistakes for all to see. If you do that, next time you post code here, no one will be able to make fun of it.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Need help with setting VGA 265-color mode

Post by Love4Boobies »

zity wrote:Well, let me give you a few more hints.
  • Also, there's no such thing as a 265-color mode (it was mentioned a couple of types so it can't be a typo).
Anyway, one of my hobbies is to do pencil portraits---I'm quite good at them too. But ask me to do anything from my imagination and I will fail miserably. In fact, I can't even make a damned website look reasonable. I can also play a few instruments but please, don't ask me to compose anything... I will clearly never be an artist and I'm okay with that. :)

Maybe I'm wrong, I can't be 100% sure from just a couple of forum posts; it could be that you just didn't know how to go about studying. However, if you have indeed wasted time, there's no point in wasting anymore of it. I advise you to take a good look at your life and make a decision. You won't want to work as a programmer if it turns out not to be your thing.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply