Closed tobiloeb closed 7 years ago
The game itself runs correctly?
Sounds like i have some buffer overflow somewhere which overwrites the milliseconds counter. Or similar ...
Did you try to uncomment parts of the menu to see which part triggers the millis malfunction?
Thanks for your fast reply. So for you the config menu is working on the arduino? I have changed your code a little bit. I am using an old super nintendo controller and changed the keys.ino.
Yes the game runs perfectly! Its awesome!!
https://github.com/tobiloeb/make-block-reloaded
Currently I have changed some more code, but it didn't work before too. Is it possible that the code got problems with the included snes classes?
The snes classes may be tje problem. Or the additional ram requirements or the like.
And yes, of course it works for me. But there may e.g. a subtile bug which only triggers a problem with a different compiler version.
Ok so I think the snes class will crash it. I am very new to arduino programming so I was wondering that it can have such an impact and only in the config menu. Everything else is working very well.
Later I will try to uncomment some parts of the config menu. Maybe I can figure out which part will crash it. Thanks for your support meanwhile!
I uncommited step by step parts from the config menu. The problem is the audio icon. If I remove the icons for audio on/off everything is working fine. The config menu will be shown with the brightness and OK icon.
Tomorrow I will check whats exactly the problem with the audio icon in my code. Thanks for your support.
Got it!! The problem was the position from audio icon. The second parameter for config_draw_icon() is the start position. For audio icon it is set to 19 but the icon itself needs 6 leds to be shown. If it starts at 19 we have an overflow of 5 leds.
I changed the code to:
void config_draw_menu(uint8_t sel) {
if(config_audio) config_draw_icon((W-sizeof(audio_on_icon))/2,14, audio_on_icon,sizeof(audio_on_icon),6, sel == 0, -1); else config_draw_icon((W-sizeof(audio_off_icon))/2,14, audio_off_icon,sizeof(audio_off_icon),6, sel == 0, -1);
config_draw_icon((W-sizeof(brightness_icon))/2,6, brightness_icon,sizeof(brightness_icon),7, sel==1, ((uint16_t)config_brightness * 14) / 255);
config_draw_icon((W-sizeof(ok_icon))/2,0, ok_icon,sizeof(ok_icon),5, sel == 2, -1); } `
The tetris game is very very cool!
Excellent. That's the kind of buffer overflow i initially expected. Thanks for finding the problem.
I have a problem with the config menu on my arduino nano. In case I press any key at startup nothing will be painted at the LEDs, so the screen stay black. In addition I can't press any key (I can but nothing happens).
So I have investigated a little bit and I found some crazy behaviors: First: In case the method "config_draw_menu" is called to show the menu, nothing happens. The method is called correctly but nothing is painted to the LEDs.
Second: Then I took a look at the loop() method from application. After each config_draw_menu call, the milliSeconds from arduino (method millis()) will be resetted to 0. So the application freezed because the next_event has a value greater then 5000 for example and millis are smaller. So after each key press in state = STATE_CONFIG, the config_draw_menu is called and reset the millis(). I have no idea whats going wrong.
In case I ran the application build with make on my computer everything is working fine. Just at the arduino nano I got this behavior.
Do you have any idea what can I do?
Thanks in advance Tobias