Morning. I decided I wanted to try and mod one of the games as a starter to uzebox programming. I decided I wanted to fix a few of the glitches in "Donkey Kong" (that is: Being able to climb a ladder when your in mid air, not being able to jump fireballs, etc.) But I ran into a problem trying to compile it. My error was:
This depends on the actual game sources. You usually have to edit the included makefile to point to the place where your uzebox kernel sources are - they are compiled into the game, but not shipped with it, remember?
Yeah sorry, my c programming experience isn't very large. The only experience I have is programming arduino's which (typically) only use one file.
Anywho I did what you said and it worked. At least partially.
Now I'm getting this:
avr-gcc -I"/home/bolle/Uzebox_Source/kernel" -mmcu=atmega644 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=28636360UL -Os -fsigned-char -ffunction-sections -MD -MP -MT DonkeyKong.o -MF dep/DonkeyKong.o.d -DVIDEO_MODE=3 -DINTRO_LOGO=0 -DSOUND_CHANNEL_4_ENABLE=0 -DSOUND_CHANNEL_2_ENABLE=1 -DSOUND_CHANNEL_3_ENABLE=1 -DMIXER_CHAN4_TYPE=1 -DMAX_SPRITES=16 -DRAM_TILES_COUNT=27 -DMIXER_WAVES=\"/home/bolle/Uzebox_Source/games/DonkeyKong/data/sounds.inc\" -c ../DonkeyKong.c
In file included from ../DonkeyKong.c:377:0:
../data/levels.inc:9:13: error: variable ‘bgMaps’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
../DonkeyKong.c:416:7: error: variable ‘pgmEnemies’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
../DonkeyKong.c:429:5: error: variable ‘frameDurations’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
../DonkeyKong.c:444:4: error: variable ‘frameSequences’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
../DonkeyKong.c: In function ‘DKLoadHiScore’:
../DonkeyKong.c:2762:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
make: *** [DonkeyKong.o] Error 1
I did a bit of googling on it but I couldn't seem to find anything to fix it. Any ideas?
I get the same error with avr-gcc 4.8. This compiler optimizes much different than previous versions of gcc and it is very picky about subtle programming errors like these. ALL of these const arrays need an additional "const"; even at the expense of e.g. having a const char* const, which the casual C programmer looks at with a raised brow.
Edit the sources and put "const" at the place where the compiler expects it. This is alright, all these are const because of PROGMEM.
EDIT: I see avr-gcc-4.8 seems to produce broken code with the Donkey Kong sources. Most likely because of optimizations, Paul has to look into this. Use an older version of avr-gcc in the meantime, 4.5.3 is fine.