[WIP] Arduventure (RPG)


(Josh Goebel) #61

It’s not ONLY the size of the memory. That’s just one consideration. It’s how often you CHANGE the specific memory location used to trigger the reboot… if you don’t change that location often then you won’t see any issues, but say if that’s where your screen buffer ends up and you’re constantly redrawing the screen - then then “reboot secret” value will get overwritten by your own code and the reboot will never be triggered. Yes, it’s a strange and weird bug. :smile:


(Wenceslao Villanueva Jr ) #62

I’ve been seeing this in my project as well. I can usually trigger it with a print to screen or outputting to the Serial terminal. I’m at 87% program storage space currently in my project and when I add a print, it jumps to 92%. Enough to cause the bug. Arduino IDE tells you what Global Vars add up to in dynamic memory. Is there a method to determining how much RAM you are using at run time? (Side note, time to optimize code size and maybe start stripping the API? Base API takes half the space right?)

Also, Siege, good work! I hope to show off my Space Roguelike soon!


#63

The program storage space doesn’t really matter, it’s the RAM usage that is important (also visible when compiling your code). But I’m sure doing the print also adds some RAM usage so that’s what’s causing the glitch. Right now there’s not much you can do about it yourself…

About stripping the API, you might be able to recover a few bytes here and there but the compiler is already quite smart and doesn’t include things you don’t use. I tried removing all drawing functions I don’t use and it didn’t make a difference in memory usage ^^’

Thanks :slight_smile: Looking forward to it :wink:


(Kevin) #64

Did we decide that this bug can be fixed with the bootloader and moving the memory space for this secret value all the way to the end of memory? Is that possible?


#65

Yeah I think that’ll fix it :)


(Kevin) #66

Arduventure is going on display at CES tomorrow! :smile:

During the chinese new year break I might try to sneak in some time to design a dev kit with SD card :smile:


#67

This looks absolutely amazing! Keep up the great work!


#68

Thanks :wink:

So I haven’t been working much on Arduventure lately as I’ve been focusing more on another not arduboy related project (for those who wonder what: Tales of Lena)

I did finish a demo last week for CES and I just decided to put it online :slight_smile: It’s more of a techdemo as you can’t finish it and there’s not much to explore. I did make battling better and added gaining exp and leveling.

You can download it here: https://codebender.cc/sketch:221132

Warning: Uploading this sketch to your Arduboy devkit will cause a glitch that will prevent you from reflashing it again! When this happens you have to short 2 pads below the screen while uploading to reset the Arduboy. You can find instructions to do this here: How to Reset the Dev Kit


#69

I can’t wait to get my hands on an Arduboy just to play test this and the hopeful finalized version! Take as many breaks as you need to, this game is looking absolutely stunning so far!


(Scott) #70

The code gives errors when I try to verify it on codebender.
(It also gives errors on my local system running Arduino IDE V1.0.5 but I can accept that from not running the latest IDE version.)


(Josh Goebel) #71

No, though it depends on what you are calling “base API”. It’s really easy to find out where the memory is going: (on a Unix system)

avr-objdump -t geoAlt2.ino.elf -C  |sort -k4 | uniq | awk --non-decimal-data '{ $5 = sprintf("%d:", "0x" $5) } 1'

You need to find the temporary folder Arduino is using (verbose logging is your friend) then just run avr-objdump on the ELF file and it will tell you how much space every single function in your codebase is using… it can be VERY informative. The command above sorts by the hogs and then pipes thru awk to turn the hex numbers into base 10 bytes used (just for niceness).

Here is a snippet (from a tail of the above command):

00002332 g F .text 270: generateBattleGainTextbox(int, int)
00004fdc g F .text 276: ArduboyCore::boot()
00005936 g F .text 288: USB_Send(unsigned char, void const*, int)
000018b8 g F .text 336: checkSpaceFree()
00004608 g F .text 354: Arduboy::drawChar(int, int, unsigned char, unsigned char, unsigned char, unsigned char)
0000078f l O .text 386: town
00001d12 g F .text 398: drawScene()
00004bd4 g F .text 428: ArduboyTunes::soundOutput()
00002748 g F .text 458: doDamageStuff(bool)
00002b50 g F .text 470: updateScene()
00002564 g F .text 484: drawBattle()
00000d11 l O .text 512: playerBitmaps
00001ade g F .text 520: updatePlayer()
00002d26 g F .text 592: doEnterName()
000033fe g F .text 656: doMenu()
00004376 g F .text 658: Arduboy::drawBitmap(int, int, unsigned char const*, int, int, unsigned char)
00003e1a g F .text 672: loop
00005b02 g F .text 712: __vector_11
0000368e g F .text 938: updateBattle()
00003a38 g F .text 994: doTextbox()
00000911 l O .text 1024: tiles
00002f76 g F .text 1160: doItemList()
00000feb l O .text 1280: font

#72

@Red
Thank you very much :smiley: I think Arduventure will really benifit from an Arduboy with an SD card slot. That way I could dynamically load maps from the SD and have a much bigger world to explore :slight_smile: I might just work on it a little bit more but I don’t think I’ll turn it into a finished game for the current Arduboy, it would just be too limited.

@MLXXXp
I’ll look into the errors on codebender, I managed to fix the 2 simple errors but then I got a whole bunch of other ones that I don’t even know what they’re about… Why is codebender giving so much errors when it works totally fine in the Arduino IDE???

(sketch file) Arduventure.ino:211:35: error: invalid input constraint 'z' in asm camX = clamp(player.x - 56, 0, (pgm_read_byte(&mapData[maps[player.currentMap].id][0]) * 8) - 128); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:212:35: error: invalid input constraint 'z' in asm camY = clamp(player.y - 24, 0, (pgm_read_byte(&mapData[maps[player.currentMap].id][1]) * 8) - 64); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:217:19: error: invalid input constraint 'z' in asm byte mapWidth = pgm_read_byte(&mapData[maps[player.currentMap].id][0]); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:218:6: error: invalid input constraint 'z' in asm if(pgm_read_byte(&mapData[maps[player.currentMap].id][((player.x + 2) / 8) + (mapWidth * ((player.y + 8) / 8)) + 2]) >= 128) return false; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:219:11: error: invalid input constraint 'z' in asm else if(pgm_read_byte(&mapData[maps[player.currentMap].id][((player.x + 13) / 8) + (mapWidth * ((player.y + 8) / 8)) + 2]) >= 128) return false; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:220:11: error: invalid input constraint 'z' in asm else if(pgm_read_byte(&mapData[maps[player.currentMap].id][((player.x + 2) / 8) + (mapWidth * ((player.y + 15) / 8)) + 2]) >= 128) return false; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:221:11: error: invalid input constraint 'z' in asm else if(pgm_read_byte(&mapData[maps[player.currentMap].id][((player.x + 13) / 8) + (mapWidth * ((player.y + 15) / 8)) + 2]) >= 128) return false; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:223:51: error: invalid input constraint 'z' in asm else if((player.y + 7) < 0 || (player.y + 16) > pgm_read_byte(&mapData[maps[player.currentMap].id][1]) * 8) return false; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:321:22: error: invalid input constraint 'z' in asm for(int i = 0; i < pgm_read_byte(&mapData[maps[player.currentMap].id][0]) * pgm_read_byte(&mapData[maps[player.currentMap].id][1]); i++) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:321:79: error: invalid input constraint 'z' in asm for(int i = 0; i < pgm_read_byte(&mapData[maps[player.currentMap].id][0]) * pgm_read_byte(&mapData[maps[player.currentMap].id][1]); i++) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:323:14: error: invalid input constraint 'z' in asm byte t = pgm_read_byte(&mapData[maps[player.currentMap].id][i + 2]); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:328:13: error: invalid input constraint 'z' in asm if(x == pgm_read_byte(&mapData[maps[player.currentMap].id][0])) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:354:44: error: invalid input constraint 'z' in asm textboxCurrentProgress = (showInstantly)?pgm_read_byte(&texts[textboxCurrentText][0]):0; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:356:22: error: invalid input constraint 'z' in asm textboxIsChoice = (pgm_read_byte(&texts[textboxCurrentText][3]) & 1)?true:false; ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:381:11: error: invalid input constraint 'z' in asm if((pgm_read_byte(&texts[textboxCurrentText][i + 4])) != NONE) arduboy.drawBitmap(4 + (i * 6) - ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?((pgm_read_byte(&texts[textboxCurrentText][1]) + 1) * 6):0), 50 + ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?6:0), font[pgm_read_byte(&texts[textboxCurrentText][i + 4])], 5, 5, WHITE); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:381:109: error: invalid input constraint 'z' in asm if((pgm_read_byte(&texts[textboxCurrentText][i + 4])) != NONE) arduboy.drawBitmap(4 + (i * 6) - ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?((pgm_read_byte(&texts[textboxCurrentText][1]) + 1) * 6):0), 50 + ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?6:0), font[pgm_read_byte(&texts[textboxCurrentText][i + 4])], 5, 5, WHITE); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:381:157: error: invalid input constraint 'z' in asm if((pgm_read_byte(&texts[textboxCurrentText][i + 4])) != NONE) arduboy.drawBitmap(4 + (i * 6) - ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?((pgm_read_byte(&texts[textboxCurrentText][1]) + 1) * 6):0), 50 + ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?6:0), font[pgm_read_byte(&texts[textboxCurrentText][i + 4])], 5, 5, WHITE); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:381:227: error: invalid input constraint 'z' in asm if((pgm_read_byte(&texts[textboxCurrentText][i + 4])) != NONE) arduboy.drawBitmap(4 + (i * 6) - ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?((pgm_read_byte(&texts[textboxCurrentText][1]) + 1) * 6):0), 50 + ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?6:0), font[pgm_read_byte(&texts[textboxCurrentText][i + 4])], 5, 5, WHITE); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:381:284: error: invalid input constraint 'z' in asm if((pgm_read_byte(&texts[textboxCurrentText][i + 4])) != NONE) arduboy.drawBitmap(4 + (i * 6) - ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?((pgm_read_byte(&texts[textboxCurrentText][1]) + 1) * 6):0), 50 + ((i > pgm_read_byte(&texts[textboxCurrentText][1]))?6:0), font[pgm_read_byte(&texts[textboxCurrentText][i + 4])], 5, 5, WHITE); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ (sketch file) Arduventure.ino:385:58: error: invalid input constraint 'z' in asm byte textLength = (textboxIsDynamic)?dynamicTextbox[0]:pgm_read_byte(&texts[textboxCurrentText][0]); ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:696:41: note: expanded from macro 'pgm_read_byte' #define pgm_read_byte(address_short) pgm_read_byte_near(address_short) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:410:43: note: expanded from macro 'pgm_read_byte_near' #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:398:29: note: expanded from macro '__LPM' #define __LPM(addr) __LPM_classic__(addr) ^ (arduino core file) hardware/tools/avr/lib/avr/include/avr/pgmspace.h:261:11: note: expanded from macro '__LPM_classic__' : "z" (__addr16) \ ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 21 errors generated.

Has anyone else been able to run it on their devkit?


(Josh Goebel) #73

Sounds like it’s confused - looks like it’s failing to compile even the core files because of some disagreement on assembler


(Josh Goebel) #74

Definitely. One way to get around this is to write a world generator and then find worlds you like and save their randoms seed value… then one value can create a HUGE replayable world… of course then the expense becomes how large (and complex) your world generation code is.

I could see this working well for a lot of the large open maps in something like Crystalis (NES). What you want to do is randomly generate a huge map and then manually place a few landmarks on it (town, treasure, special locations, etc)… then you get the feel of a large world but also the feeling of static design.

Of course the next limit you’ll hit is just the storage of text, story, etc… 32kb goes fast.


(Josh Goebel) #75

Do you want a chance to put this on Github first and then I can fork your repository to make my own, or do you not care? I’m about to put it on there so people can more easily see it and contribute to it if they want. I was going to see if any of the menu stuff you’ve done could be easily abstracted into a library and look at where all that space went.


#76

Sure, go ahead :slight_smile: I’ve never used GitHub before ^^’ I’m sure there is a lot of room for optimization :wink: I’m currently busy with another project so I won’t be working much on it any time soon.


(Josh Goebel) #77

Any time you see yourself repeating oyurelf is probably room to optimize… such as where you do the same logic 4 times in updatePlayer()… you should probably instead have an array:

pseudo array:

[
[LEFT_BUTTON, X_DIR, -1],
[RIGHT_BUTTON, X_DIR, 1],
[UP_BUTTON, Y_DIR , -1],
[DOWN_BUTTON, Y_DIR , +1],
]

Then loop over that array 4 times running the SAME bounds checking code just using tweaks from the array. That would possibly reduce the size of updatePlayer 4x probably.

Do you have raw graphic resources for your tiles vs the include files?

Also it’s possible direction should instead be a param to checkSpaceFree and checkDoors to avoid moving the player back and forth just to do checks.


#78

True :wink: I never bothered to make that part better as I just wanted to move on and add more features. Any optimization is good though and thanks for sharing a possible solution :smile:

There’s one part in the code I really don’t know if it’s optimized or not… For the textboxes I do a lot of dynamic generating, for example when you attack it generates something like: [enemy name] + “took” + [player attack - enemy defense] + “damage!”. I found out using caused a major memory bump so I did it in a different way. Now I don’t know if that way is actually better or not ^^’

I’ll post the raw graphic resources when I get home :wink:


(Josh Goebel) #79

Yeah, work could be spent there to make those code paths a lot more similar… (dynamic vs non). I gave up messing with any of the string stuff when I saw you invented your own alphabet. The strings should be in ASCII - let the program convert them to your font.


#80

A bit late but here are the images: https://www.dropbox.com/s/tfjee68uej1z60c/images.zip?dl=0
Feel free to upload them somewhere more accessible :wink: