gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

OffTopic > I am an idiot

#61831 - gauauu - Thu Nov 24, 2005 3:25 am

Ok, I was dumb enough yesterday that I have to tell you all about it.

I was having some weird glitches in my code when I scrolled my map around. Weird seams and things didn't seem right. I kept checking all my map scrolling routines and everything was definitely right, so I couldn't really figure it out. I went through and disabled everything in my code, like sprites and other backgrounds, trying to pinpoint the issue, but no luck.

So I was about to post here to ask for advice. I was thinking through how to describe the problem, when I thought "the best way to describe it is tearing".......OH....DUH...somehow I had spent hours staring at my scrolling routine, and it had never occurred to me to check that I hadn't messed up my "wait for vblank" routine. It's only what, one of the most common problems with such an obvious symptom? Of course, that was the issue - I was scrolling in the middle of drawing the screen.

The funniest part about it was that afterward, I described the problem to my completely non-techie, non-programmer wife, who said "well, that sounds like that problem you had told me about once before where you change things while the screen is drawing"......when my wife could diagnose the problem and I couldn't, you know there's a problem.

So, if there's an important lesson to be learned here today, it is this:
I am an idiot.

#61850 - DiscoBoy - Thu Nov 24, 2005 7:53 am

Thanks for sharing :-)

#61853 - sgeos - Thu Nov 24, 2005 8:11 am

I shared my divide by zero hidden in a loop a long while back.

-Brendan

#61860 - keldon - Thu Nov 24, 2005 9:00 am

I think that when ones non programming other half diagnoses ones programming problems then we have a problem =)

#61871 - gladius - Thu Nov 24, 2005 11:50 am

This is a fun bug a coworker hit a few days ago:

if (condition);
{
// do what you should do in the condition
}

No compiler warning or anything :)

#61872 - chishm - Thu Nov 24, 2005 12:09 pm

Here's a confusing one:
Code:

int x = 3;
while (x--)
    output (x);
outputFinal(x);

versus
Code:

int x = 3;
while (--x)
    output (x);
outputFinal(x);

The first one outputs 2,1,0 final -1. The second one outputs 2,1, final 0.
The lesson? Be aware of pre- and post- decrement operators.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#61877 - Cearn - Thu Nov 24, 2005 1:00 pm

gladius wrote:
This is a fun bug a coworker hit a few days ago:

if (condition);
{
// do what you should do in the condition
}

No compiler warning or anything :)

Gaah! I wasted hours on something like that a long while back. Not something you want to find out about at 4am.

#61989 - sgeos - Sat Nov 26, 2005 7:24 am

chishm wrote:
The lesson? Be aware of pre- and post- decrement operators.

I never use pre/post decrement in compound statements. I only use:
Code:
x++;
x--;

OR
Code:
for (i = start; i < max; i++)
{
}


-Brendan

#62000 - keldon - Sat Nov 26, 2005 9:51 am

It is often the case that it would have cost you much less time to have started your code from scratch. The fact that you made the mistake in the first place means that you have alreay become partially blind to it.

It is much like a search for a needle in a haystack as it is much easier to take everything outside of the barn and put it back piece by piece than it is to actually search for the needle to remove it.

#62222 - thos_thom - Mon Nov 28, 2005 1:11 pm

i find this funny:

if(++i-->someVariable)
doSomthing();

as a replacement for

if((i+1)>someVariable)
doSomthing();

which is clearer i ask you? i guess it depends on how tired you are.
_________________
--------------
^thom(as)?
--------------