Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post

Link to post
Share on other sites
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


Edited by - The_[PI]_ehT on July 23, 2000 2:16:21 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!