Image Map Image Map
Page 3 of 16 FirstFirst 123456713 ... LastLast
Results 21 to 30 of 151

Thread: VGA & CGA Graphics Library for DOS Games

  1. #21

    Default

    I almost got the loadBMP function working... there is something wrong with the colors I'm guessing I need to change the palette but I don't know if thats inside the BMP file.
    Also, how does the loadBMP function look like?

    Attachment 36011

    Thanks!

  2. #22
    Join Date
    Sep 2011
    Location
    Toronto, Canada
    Posts
    150

    Default

    The palette is indeed inside the BMP file. But it's stored as BGR instead of RGB so you have to flip it around, I believe its right after the header.
    Currently working on new DOS game, Chuck Jones: Space Cop of the Future, Check out my Dev Blog

    Vintage Computers:
    Unitron Apple II clone, 2x Commodore Vic-20, Commodore 64, Commodore 128, Amiga 500, Macintosh Plus, Macintosh SE, 3 386sx PCs, Atari TT030

  3. #23
    Join Date
    Dec 2014
    Location
    The Netherlands
    Posts
    1,455

    Default

    Quote Originally Posted by Trixter View Post
    I agree making your own library is the most fun, but isn't always the most practical. When he said he wanted to start throwing in input handling and sound (the latter of which is not easy to tackle for a beginner), I figured why reinvent the wheel?
    I think perhaps we could combine forces.
    I'm doing my own includes and headers. I know reenigne also has his library of things (I borrowed some of his macros/ideas for my own stuff). And many others probably do the same.
    My aim is to do something similar to the Amiga NDK, where you get C and assembly headers and libraries to interface with all standard hardware and OS/ROM libraries.
    Think of it as Ralfs Interrupt List and Bochs ports.lst in source code form. So you can use them as documentation, but you can also use them directly in your code.

    I currently have the 6845, 8253 and 8259 mostly covered.
    I may do the 8257 next, doing a simple test project with digital playback on Sound Blaster.

  4. #24

    Default

    I can't make the color palette work... can anyone see what I'm doing wrong?
    Attachment 36024

  5. #25
    Join Date
    Sep 2011
    Location
    Toronto, Canada
    Posts
    150

    Default

    You are reading the palette as RGB but it is stored in the BMP as BGR (bmp files are backwards on lots of things), the palette is also stored before the image data and is not guaranteed to be 16 colors, it is however long as is listed in the header's number of colors entry
    Currently working on new DOS game, Chuck Jones: Space Cop of the Future, Check out my Dev Blog

    Vintage Computers:
    Unitron Apple II clone, 2x Commodore Vic-20, Commodore 64, Commodore 128, Amiga 500, Macintosh Plus, Macintosh SE, 3 386sx PCs, Atari TT030

  6. #26

    Default

    Quote Originally Posted by PgrAm View Post
    You are reading the palette as RGB but it is stored in the BMP as BGR (bmp files are backwards on lots of things), the palette is also stored before the image data and is not guaranteed to be 16 colors, it is however long as is listed in the header's number of colors entry
    It doesn't change anything if I use RGB or BGR thats the weird thing. How are the bytes supposed to be stored in memory? if I have 4 bits per pixel lets say: 0xFF or 0b11111111 so how do I have to store them in video memoruy? like this: 00001111 for memory location A000:0000 and 11110000 for A000:0001 ?

  7. #27
    Join Date
    Dec 2014
    Location
    The Netherlands
    Posts
    1,455

    Default

    Quote Originally Posted by NicolasF View Post
    It doesn't change anything if I use RGB or BGR thats the weird thing. How are the bytes supposed to be stored in memory? if I have 4 bits per pixel lets say: 0xFF or 0b11111111 so how do I have to store them in video memoruy? like this: 00001111 for memory location A000:0000 and 11110000 for A000:0001 ?

    With 4 bits per pixel you mean the 16-colour EGA and VGA modes? Those are bitplane modes, not chunky modes. So you have 4 bitplanes, and a special control register to select which plane(s) you write your data to. Each byte contains 8 pixels.
    Goes a bit far to try and explain the entire concept in a single post.

  8. #28

    Default

    Quote Originally Posted by NicolasF View Post
    It doesn't change anything if I use RGB or BGR thats the weird thing. How are the bytes supposed to be stored in memory? if I have 4 bits per pixel lets say: 0xFF or 0b11111111 so how do I have to store them in video memoruy? like this: 00001111 for memory location A000:0000 and 11110000 for A000:0001 ?
    Can you post a screenshot of what your program is displaying at the moment?

  9. #29

    Default

    Finally! I got it working. I had to bitshift by 2 the value of the palette color because it goes from 0 to 63 and the BMP file has values greater than those, thats why.
    Also, PgrAm was right, colors are stored BGR... I'll have to read more about those bitplanes stuff I've never heard of that before.

    Attachment 36052

    MAIN.jpg

  10. #30
    Join Date
    Dec 2014
    Location
    The Netherlands
    Posts
    1,455

    Default

    Quote Originally Posted by NicolasF View Post
    Finally! I got it working. I had to bitshift by 2 the value of the palette color because it goes from 0 to 63 and the BMP file has values greater than those, thats why.
    Ah yes, VGA only has an 18-bit palette, so 6 bits per component. BMP and most other formats use the more common 24-bit format, 8 bits per component.

    Quote Originally Posted by NicolasF View Post
    I'll have to read more about those bitplanes stuff I've never heard of that before.
    They allow for some very interesting tricks.
    It's very simply to only update one bit of the colours on screen, which you can use for overlays/transparency, for example.

Page 3 of 16 FirstFirst 123456713 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •