problems with the first tutorial :(

This is a discussion on problems with the first tutorial :( within the C++ Programming forums, part of the General Programming Boards category; I'm getting errors with the first graphic tutorial. why did it had to contain ASM-language (( Anyway, this is what ...

  1. #1
    Unregistered
    Guest

    problems with the first tutorial :(

    I'm getting errors with the first graphic tutorial.
    why did it had to contain ASM-language ((

    Anyway, this is what my program looks like:

    void SetMCGA(void);
    void MEMPutpixel(int, int, unsigned char);
    int vga=0xa000;

    void main()
    {
    int x=100, y=100;
    SetMCGA();
    MEMPutpixel(x,y,100);
    }

    void MEMPutpixel (int x, int y, unsigned char Col)
    {
    memset(vga+x+(y*320),Col,1);
    }

    void SetText()
    {
    _AX = 0x0003;
    geninterrupt(0x10);
    }

    void SetMCGA()
    {
    _AX = 0x0013;
    geninterrupt (0x10);
    }


    I get errors on the MEMPutpixel thing, saying:
    Error BIN\Grap.CPP 60: Cannot convert 'int' to 'void *'
    Error BIN\Grap.CPP 60: Type mismatch in parameter '__s' in call to 'memset(void *,int,unsigned int)'

    I don't understand what's wrong. I used the exact code from the tutorial.
    Anyone could help me out here???

    Thanks in advance,

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    instead of

    int vga=0xa000;

    try:

    int * vga=0xa000;

  3. #3
    Unregistered
    Guest
    Thanks traveller, I'll try that...

    => Error CODE\GRAPHASM.CPP 20: Cannot convert 'unsigned int' to 'int *'

    Nope.

    Btw, is it ok to post this here or should I have posted this in the DOS C forum instead? I'm rather new to the board (got here today, the board that is) so don't know that good how it goes around here.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    317
    Code:
    unsigned char *vga=(unsigned char *)0xA000;
    This should work. No, its fine to post this question here. The C++ board is really for generalized questions on C++ programming whereas the other boards get more specialized into areas designated by their names. However its not like you'll be stoned or anything.
    Last edited by Traveller; 07-13-2002 at 08:29 PM.

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    i might be wrong about this,
    but wouldn't the address be 0xA0000 instead of 0xA000?
    in protected mode flat memory addressing it's 0xA0000.
    0xA000 is used in a real-mode segmented model as a segment:
    0xA000:0x1234 for instance.

    or i could be completely wrong. just fyi, if it doesn't work, something to try.

  6. #6
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Besides vga being a unsigned char*
    you really shouldn't use memset just to plot a pixel.

    Try this

    Code:
    inline void MEMPutpixel (int x, int y, unsigned char color) 
    { 
          vga[x + y*320] = color; 
    }

  7. #7
    Unregistered
    Guest
    Hm, yes thanks fellas, not anymore the errors.

    But using it like that, initializing my graphics thru ASM-language.
    I run it and this is what happens:
    I see the screen flash (going to graphic mode) with some -VERY VERY SHORT- color at the top of my screen, centered and then going back to the editor.

    So, I can't get to the part where the pixel are put on screen.
    I've tried this to notice if it actually works:
    -Initialize the graphic mode
    -Put many pixel on
    -Then a delay or sleep that would give me some seconds to see if there's actually a pixel colored or not.

    It does not wait at all. So it just skips till the end of my program???

    Anyway I can compile it now with no errors and run it without any visual errors, but when compiled and maked (so I have the exe),
    and run the exe it pops up, goes back to a standard window format and says in big white letters:
    "BGI Error: Grahpics not initialized (use 'initgraph')"

    But just because BGI has some cons, so says the first graphic tutorial on the site here, I tried with the assembly language.
    So, where might the problem be?
    Or some simple ASM-piece of code that I must use?

    For a newbie to it, I really depent on others. I hope you people can help me out here.

  8. #8
    Unregistered
    Guest
    Anyone??? Please

  9. #9
    Unregistered
    Guest
    bummer

  10. #10
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    you should get a username if you plan to hang out here. it is just good if people know who you are aftr a while theyll know how you work with c++ and how to answer your questiopns, well thats what happenes to me qwhen ne wpeople come. though i am not to helpful, the only board i was ever helpul was glash 'n smash (a flash 5 board) which is now gone
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 03:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. openGL problems (glut)
    By c_young in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2007, 01:27 PM
  4. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  5. My DirectInput tutorial....
    By jdinger in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-19-2002, 12:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21