Page 1 of 1

Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 10:59 am
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;
}

Re: Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 12:31 pm
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.

Re: Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 2:34 pm
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.

Re: Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 3:37 pm
by Aaron
Gigasoft wrote:You've just started to learn programming
I'm not new to programming at all. Try not to assume. :/

Re: Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 3:41 pm
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.

Re: Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 3:54 pm
by Gigasoft
And, notice that "265-color mode" is mentioned twice :P

Re: Need help with setting VGA 265-color mode

Posted: Fri Jun 17, 2011 3:58 pm
by Love4Boobies
Heh, I didn't even notice that :lol:

Re: Need help with setting VGA 265-color mode

Posted: Sat Jun 18, 2011 12:34 am
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. :?

Re: Need help with setting VGA 265-color mode

Posted: Sat Jun 18, 2011 12:51 am
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.

Re: Need help with setting VGA 265-color mode

Posted: Sat Jun 18, 2011 2:00 am
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.

Re: Need help with setting VGA 265-color mode

Posted: Sat Jun 18, 2011 1:21 pm
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.

Re: Need help with setting VGA 265-color mode

Posted: Sat Jun 18, 2011 8:55 pm
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.