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]