I was looking at some code to change the video mode in djgpp and i did this
#include
__dpmi_regs regs;
regs.x.ax = 0X13;
__dpmi_int(0X10,®s);
I also add a pixel by doing:
#include
#include
_farpokeb(_dos_ds,0XA0000,1);
when I ran this it crashed my computer, but I found another piece of code that put the line:
memset(®s,0,sizeof(regs));
before the regs.x.ax = 0X13 line.
Can someone tell me why memset fixed this or why my computer crashed the first time?
Thanks and How do you make you source look like source code in the white box when you post?
It's because you didn't set all members of the regs structure to a value, so maybe some of them still held "memory crap" (anything but 0) in it, because C doesn't set your variables to 0 automatically, it just says "this variable is at this'n'this point in memory, not important to me what the mem contained before". So you should always perform a memset( &x, 0, sizeof(x)) operation on your structures / arrays, especially if you're doing operations which access the hardware directly (just remember the random-on-all-ports-equals-fun-and-btw-you-gotta-buy-a-new-machine-thingie)
ah yes, and you used dpmi, so i think this is why it crashed - dpmi is a bit sensitive about operations which access hardware directly
hope this helps
pi~
Edited by - The_[PI]_ehT on July 23, 2000 2:16:21 PM
ah yes, and you used dpmi, so i think this is why it crashed - dpmi is a bit sensitive about operations which access hardware directly
hope this helps
pi~
Edited by - The_[PI]_ehT on July 23, 2000 2:16:21 PM
Jan PieczkowskiBrainwave Studios
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement