Help - Search - Members - Calendar
Full Version: Floating Point Division By 0!
Game Maker Community > Working with Game Maker > Advanced Users Only
Recreate
Well one day I was playing around with the window size until I got a Floating point division by 0 error message.
I screen recorded it in HD, Here is the video

So...Can someone tell me why this happened?
Thanks
~ReCreate
hanson
You have no code dividing by window height, right? If not that, it may be an issue with GM's scaling code. Try it with an empty room and see if this still happens.
Recreate
Hmmm...that could be it, But I don't think I had anything doing that, I noticed it only happened when in 3D mode.
And if it was that, Wouldn't it just say Division by 0?
Tepi
Might have to do with calculating the aspect ratio. That's where one would divide by the height.
xot
Yeah, I've seen this before, and I think Tepi probably has it exactly right.

http://gmc.yoyogames.com/index.php?showtopic=426071
http://www.gmlscripts.com/forums/viewtopic.php?id=1572

Interestingly, the problem doesn't seem to affect GM6. It has apparently been fixed for GM8.

http://gm8.yoyogames.com/view.php?id=343
Recreate
Oh well then, But where and why would GM calculate the aspect ratio?
B&B_Gaming
QUOTE (Recreate @ Nov 10 2009, 12:36 PM) *
Oh well then, But where and why would GM calculate the aspect ratio?

Does it matter?
Recreate
Matters big time...
score_under
Fix: (GM7.gif GM7 Only!)

Open your compiled game in a hex editor.

Go to 09CA08. (This offset is in hex)
You should see the bytes:
"DB 45 E0 DE F1"
Replace them with:
"E9 93 3C 0E 00".

Next, go to 180696. (This offset is also in hex)
You should see:
"6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A"
Replace with: (Most hex editors have a "paste hex" function)
"B1 12 6A 00 FE C9 75 FA EB 1A 6A 00 DB 14 24 83 3C 24 00 75 04 D9 E8 DE C1 DB 45 E0 DE F1 E9 54 C3 F1 FF"

Bear in mind though, that this code will be replaced if you use the anti-decompiler. Just use the anti-decompiler first, apply the patch next, then optionally apply the compressor last.

Recreate
You seem to know a lot with GM's EXE data structure...
score_under
It's one of the few cases where I actually use a debugger for... debugging wink1.gif
halo shg
My goodness, I don't know how you managed to get that, but that's incredible. Keep up the good work!
StarTrek
QUOTE (score_under @ Nov 14 2009, 01:08 AM) *
Fix: (GM7.gif GM7 Only!)

Open your compiled game in a hex editor.

Go to 09CA08. (This offset is in hex)
You should see the bytes:
"DB 45 E0 DE F1"
Replace them with:
"E9 93 3C 0E 00".

Next, go to 180696. (This offset is also in hex)
You should see:
"6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A"
Replace with: (Most hex editors have a "paste hex" function)
"B1 12 6A 00 FE C9 75 FA EB 1A 6A 00 DB 14 24 83 3C 24 00 75 04 D9 E8 DE C1 DB 45 E0 DE F1 E9 54 C3 F1 FF"

Bear in mind though, that this code will be replaced if you use the anti-decompiler. Just use the anti-decompiler first, apply the patch next, then optionally apply the compressor last.

I'm not doubting that it works... but may I ask HOW it works? tongue.gif
score_under
QUOTE (StarTrek @ Nov 15 2009, 07:41 PM) *
I'm not doubting that it works... but may I ask HOW it works? tongue.gif


Did a little ASM hacking, optimized 18 "push 0" into a much shorter loop of pushes (using CL as counter; yes, I did check that it is not needed later), then used the free space left over to implement a check for the division by zero and avert it. I then just JMP'd to this free space from the original location, and JMP'd back when the check finished.
Gamer3D
QUOTE (Recreate @ Nov 10 2009, 10:36 AM) *
Oh well then, But where and why would GM calculate the aspect ratio?

It is probably used when calling functions in Direct3D. I don't think Mark expected someone to create a 0 width or height view/room.
slayer 64
i don't think mark overmars expected game maker to be anything.
Recreate
Explain. You make no sense.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.