DIBs for 3-d thingie?

Started by
18 comments, last by n0ob 21 years ago
quote:Original post by n0ob
um, no, I don't want to use SetPixel().. What would YOU recommend I use??? Or is that "because you can't use 3d hardware." a hint that I need to somehow access my 3d hardware for my realtime wants. Any keywords of what I should use?? Thanks

liero probably used mode 0x13, which is very easy to plot pixels with. just (SomeAddressICantRememberYoullHaveToResearch) + y * 320 + x = Your256Color here. its very simple asm to initialize 13h if i remember correctly. here is what the code could basically look like:

void Init13h(){   __asm   {      (some code here i can't remember, basically moves 0x13 into a register)      int 10 // not totally sure if this is the correct interrupt, but i think that was it   }}void PlotPixel(int x, int y, int Color){   int * Offset = (int *)ThatAddressYouHaveToResearch + y * 320 + x   *Offset = Color;  // broke this down to make it easier to understand}void PlotPixelRow(int x, int y, unsigned char * Colors, int PixelCount){   memcpy((void*)(ThatAddressYouHaveToResearch + y * 320 + x), Colors, PixelCount);  // NOT SURE THIS WILL WORK, but i its the right idea}     

to draw a sprite, you would iterate through each row of the sprite and use PlotPixelRow, you could use PlotPixel but if i remember right that was slow.

you have to clip stuff that goes off the left or right edge of the screen, and ABSOLUTELY have to clip stuff that goes off the top or bottom. going off the left and right simply wraps to the other side, which is undesirable. moving off the top or bottom is a good chance of an access violation.

note this is palletted mode, i forgot how you change the colors of a pallette index.

edit: dumb typo

edit again: i noticed this function won't work:
void PlotPixel(int x, int y, int Color){      int * Offset = (int *)ThatAddressYouHaveToResearch + y * 320 + x   *Offset = Color;  // broke this down to make it easier to understand}  

that will overwrite the next 4 pixels, because its copying an int, this should work:
void PlotPixel(int x, int y, unsigned char Color){      unsigned char * Offset = (unsigned char *)ThatAddressYouHaveToResearch + y * 320 + x;   *Offset = Color;  // broke this down to make it easier to understand}}  


[edited by - billybob on April 20, 2003 1:17:28 AM]

[edited by - billybob on April 20, 2003 1:28:39 AM]

[edited by - billybob on April 20, 2003 1:29:31 AM]
Advertisement
OOOH OOHH GENIUS!!! FLASH OF INSPIRATION!!! I hope drawing 307,200 points won't be too slow! THANKS YOU I FINALLY GET IT!

OOH BILLYBOB I LOVE YOU THAT'S EVEN BETTER SWEEET YES YES YES!!!! THANK YOU THANK YOU!!! I'll start searching!

Kings of Chaos

[edited by - n0ob on April 20, 2003 1:19:09 AM]
Yeah, I don't know anything about 13h (being 13, it was outdated before I even started trying to start to code ) except that it was 320x200(I think)

320x200 = 64,000 how do you expect to get that larger number? And why use old stuff when you dan't have to? And here's an old tutorial, if you want it: http://www.brackeen.com/home/vga/

-~-The Cow of Darkness-~-



[edited by - cowsarenotevil on April 20, 2003 1:25:28 AM]
-~-The Cow of Darkness-~-
and since this is bringing up nice memories, and i want to remember more , this is what a sprite class would look like:

class Sprite{   unsigned char * Data;   int Width;   int Height;public:   Sprite() : Data(NULL), Width(0), Height(0) { }   Sprite(int x, int y) : Width(x), Height(y)   {       Data = new unsigned char[x * y];    }   ~Sprite()    {      if(Data)         delete [] Data;   }      void Draw(int x, int y)   {      for(int i = 0; i < Height; ++i)      {         PlotPixelRow(x, y + i, &Data, Width);<br>      }<br>   }<br>   void SetSpritePixel(int x, int y, unsigned char Color)<br>   {<br>      Data[y * Width + x] = Color;  // needs clipping so you don''t run over other stuff''s memory<br>   }<br>}<br> </pre> <br>you''d need more functions to load and save, probably &#111;ne to load bitmaps.    
quote:Original post by cowsarenotevil
Yeah, I don''t know anything about 13h (being 13, it was outdated before I even started trying to start to code ) except that it was 320x240(I think)

320x200 = 64,000 how do you expect to get that larger number? And why use old stuff when you dan''t have to? And here''s an old tutorial, if you want it: http://www.brackeen.com/home/vga/

-~-The Cow of Darkness-~-

its 320x200, i told him that because he was talking about liero, which looks like mode 13h

yeah, i was like 11 when i was trying this, it makes a lot more sense now, (16) lol.
yah i'm 7 years old, i should probably wait a couple years..
my billion pixel number was 640x480 tho Thank you a ton!!

Kings of Chaos

er, doh, i didn't hit the 1, that's 17 years old. Not impressive

[edited by - n0ob on April 20, 2003 1:38:06 AM]
quote:Original post by n0ob
yah i''m 7 years old, i should probably wait a couple years..
my billion pixel number was 640x480 tho Thank you a ton!!

Kings of Chaos

7? Seriously? Wow... that''s awesome. You seem to actually know something too. How good are you at math?



-~-The Cow of Darkness-~-
-~-The Cow of Darkness-~-
quote:Original post by n0ob
yah i'm 7 years old, i should probably wait a couple years..
my billion pixel number was 640x480 tho Thank you a ton!!

err, probably don't want to mess with that stuff i gave you then, wait a few years, i got it working (single pixel plotting, no dynamic memory on sprites) when i was around 11, but didn't really understand it until a few years ago around 14 or 15.

oh, 17, might be able to handle it then, depends on how well you know memory and pointers, i'm not sure where kids my age are supposed to be. the asm is VERY simple, i still don't anything beyond 3 lines of inline asm, but that int 10 calling is super simple.

[edited by - billybob on April 20, 2003 1:43:59 AM]
sorry, i edited my last post

Kings of Chaos

[edited by - n0ob on April 20, 2003 1:41:33 AM]
i think there was more stuff i had to do also, before it can plot pixels, but i can''t remember. there should be some old tutorials lying around.

This topic is closed to new replies.

Advertisement