#21841 - expos1994 - Mon Jun 07, 2004 3:53 pm
Hello,
I am having a weird problem with my code. It has held me up since yesterday afternoon. What happens is I write some text to background 2 (mode 0). Then I wait for the A or B button to be pressed. Then I clear the background and write some more text to the same background. Then again I wait for A or B.
After this happens, the code freezes. If I swap around a few lines here and there I can get it to basically do a restart of main(). I have no idea why this is happening. Logically it seems fine. I have tried so many different things and have gotten some interesting results. None are the ones I want however.
If I take out the code that waits for button presses and the code that writes the background text, and just put some simple assignments in the procedure, it will run through it without problems. So I'm guessing it is one of those things that is breaking my code.
Here's basically what I'm doing (I don't have the exact code since I'm at work. But maybe you guys won't need it. I can post it at another time.
My waitforAB() basically is a loop that won't break; until A or B is pressed. And the while() I added under that is to wait until A (I'll add B later), is unpressed.
I use this combination in other spots in my code... DrawWindow()/waitforAB(), and it has no problem. It works fine. But in this particular function, called from main. It just won't allow it.
Can anyone provide insight into this? It's frustrating because it seems to have a mind of it's own, but I think I'm just not quite understanding something.
Thanks for any help. If you need more code, I'll post it.
--Chris
I am having a weird problem with my code. It has held me up since yesterday afternoon. What happens is I write some text to background 2 (mode 0). Then I wait for the A or B button to be pressed. Then I clear the background and write some more text to the same background. Then again I wait for A or B.
After this happens, the code freezes. If I swap around a few lines here and there I can get it to basically do a restart of main(). I have no idea why this is happening. Logically it seems fine. I have tried so many different things and have gotten some interesting results. None are the ones I want however.
If I take out the code that waits for button presses and the code that writes the background text, and just put some simple assignments in the procedure, it will run through it without problems. So I'm guessing it is one of those things that is breaking my code.
Here's basically what I'm doing (I don't have the exact code since I'm at work. But maybe you guys won't need it. I can post it at another time.
Code: |
void dolandmark() { strcpy(message, "This is my message ... blah blah"); DrawWindow(message, 0,5,20); waitforAB(); while(!(KEYS & KEY_A); //I put this in to try and solve my problem. It seems to help but it still freezes right below this. //I do a little bit here. Some assignments strcpy(message, "The second message"); DrawWindow(message, 0,5,20); waitforAB(); while(!(KEYS & KEY_A); } //What I'm expecting now is that it would return to the calling function ... main(), but it freezes or in some cases restarts at the beginning of main. In this state, it freezes. This is very frustrating. It is acting the same way on the hardware and VBA. |
My waitforAB() basically is a loop that won't break; until A or B is pressed. And the while() I added under that is to wait until A (I'll add B later), is unpressed.
I use this combination in other spots in my code... DrawWindow()/waitforAB(), and it has no problem. It works fine. But in this particular function, called from main. It just won't allow it.
Can anyone provide insight into this? It's frustrating because it seems to have a mind of it's own, but I think I'm just not quite understanding something.
Thanks for any help. If you need more code, I'll post it.
--Chris