#define pgm_read..... errors

ok so ive been building a library for gamesystem that will allow any one to write and play their own games. I was hung up on the drawbitmap functions along with the tilemap functions but ive since then completed that part and a whole lot more and I seem to be stuck at something ive never dealt with.

its giving me problems with pgmspace.h in teensy. I looked at the file and it looks right but the weird thing is that I cant find the regular arduino version on my computer. do I need to download the regular arduino version?

here are the actual errors....

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:11:0,

                 from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Arduino.h:1,

                 from C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolor\Sound.h:23,

                 from C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolor\Sound.cpp:20:

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolor\Sound.cpp: In member function 'void Sound::updateTrack(uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/pgmspace.h:80:61: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

 #define pgm_read_word(addr) (*(const unsigned short *)(addr))

                                                             ^

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolor\Sound.cpp:124:32: note: in expansion of macro 'pgm_read_word'

   playPattern((const uint16_t*)pgm_read_word(&(patternSet[channel][patternID])), channel);

                                ^

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolor\Sound.cpp: In member function 'void Sound::command(uint8_t, uint8_t, int8_t, uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/pgmspace.h:80:61: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

 #define pgm_read_word(addr) (*(const unsigned short *)(addr))

heres the bit of code it refers to

int8_t Gamebuino::menu(const char* const* items, uint8_t length) {
#if (ENABLE_GUI > 0)
	display.persistence = false;
	int8_t activeItem = 0;
	int8_t currentY = LCDHEIGHT;
	int8_t targetY = 0;
	boolean exit = false;
	int8_t answer = -1;
	while (1) {
		if (update()) {
			if (buttons.pressed(BTN_A) || buttons.pressed(BTN_B) || buttons.pressed(BTN_C)) {
				exit = true; //time to exit menu !
				targetY = - display.fontHeight * length - 2; //send the menu out of the screen
				if (buttons.pressed(BTN_A)) {
					answer = activeItem;
					sound.playOK();
				} else {
					sound.playCancel();
				}
			}
			if (exit == false) {
				if (buttons.repeat(BTN_DOWN,4)) {
					activeItem++;
					sound.playTick();
				}
				if (buttons.repeat(BTN_UP,4)) {
					activeItem--;
					sound.playTick();
				}
				//don't go out of the menu
				if (activeItem == length) activeItem = 0;
				if (activeItem < 0) activeItem = length - 1;

				targetY = -display.fontHeight * activeItem + (display.fontHeight+4); //center the menu on the active item
			} else { //exit :
				if ((currentY - targetY) <= 1)
				return (answer);
			}
			//draw a fancy menu
			currentY = (currentY + targetY) / 2;
			display.cursorX = 0;
			display.cursorY = currentY;
			display.fontSize = 1;
			display.textWrap = false;
			for (byte i = 0; i < length; i++) {
				if (i == activeItem){
					display.cursorX = 3;
					display.cursorY = currentY + display.fontHeight * activeItem;
				}
				display.println((const __FlashStringHelper*)pgm_read_word(items+i));
			}

			//display.fillRect(0, currentY + 3 + 8 * activeItem, 2, 2, BLACK);
			//display.setColor(WHITE); //color UNSET BY DUHJOKER
			display.drawFastHLine(0, currentY + display.fontHeight * activeItem - 1, LCDWIDTH, WHITE); //DUHJOKER
			//display.setColor(BLACK);  //color UNSET BY DUHJOKER 
			display.drawRoundRect(0, currentY + display.fontHeight * activeItem - 2, LCDWIDTH, (display.fontHeight+3), 3, BLACK); //DUHJOKER
		}
	}
#else
	return 0;
#endif
}

the working sketch is included in the file

 playPattern((const uint16_t*)pgm_read_word(&(patternSet[channel][patternID]))

pointers on Teensy are 32bits, so you can't cast a pgm_read_word() (which returns 16bits) to a pointer
I suggest a new macro "pgm_read_pointer" that gets set to either pgm_read_word or pgm_read_dword depending on the processor. You may have alignment problems, and your datastructure might be all shot to hell.

pointers on Teensy are 32bits, so you can't cast a pgm_read_word() (which returns 16bits) to a pointer

Sure you can. You couldn't meaningfully cast a 32 pointer to a 16 bit pointer, but casting to a larger size is always valid. The value is an address. There will be lots of room for the 16 bit address in the 32 bit pointer.

Ok so what do I actually need to do to fix the problem.

Weird thing is that that part of the code is the original Gamebuino code. So why did it change? All I did was was add color stuff.

You couldn't meaningfully cast a 32 pointer to a 16 bit pointer, but casting to a larger size is always valid.

Doesn't generate any warnings from the compiler? That whole "cast to pointer from integer of different size" is exactly how I'd describe it...

I don't know if that's the only problem, but the whole sizeof(int) thing is what I'd be looking for in porting from AVR to ARM...

Ok so the LCD files source use int16_t and int16_t. So I need to replace any unit8_t and int8_t with the new integers?

so the LCD files source use int16_t and int16_t. So I need to replace any unit8_t and int8_t with the new integers?

No, I don't think so. You need to fix the locations where it reads a word (16bits) from pgmspace and then tries to use it as a pointer (32bits) The data structures themselves look OK (have "uint16_t *" as appropriate), and I only see the two cases in Sound.c, but I'm not familiar enough with Gamebuino to know whether there's likely to be a deeper problem.

I cant figure it out. I pulled up both progmem files, arduino and teensy and the files are almost identical. Just a couple more definitions than the other.

Any way... They both list and define uint_t and int_t all the way from 8 to 64.

Does any one know if i can use pcd8544 with this library. The og gamebuino files use it and it would be a good thing to know.

I see that it works with the color nokia but ive had to change so much id rather know ahead of time

Is it the arguments in the () brackets that are causing the error?

I think i might understand a lil better.

the pointer im casting to is 16bit but the teensy runs 32 bit. So instead of casting pgm_read_byte, i need to use the far version?

Probably you need to use "pgm_read_ptr" instead of "pgm_read_word"

Really I just want to use 16bit capabilities.

Ok i tried every thing on the pgm list that was in the pgmspace file and i still get the errors.

I was actually told i didnt need to use pgm space with the arm chip?

Could the nessacary pgm space defines and integers or what ever be added to my library then cut the include for pgm space out of my library sources?

Im really grasping at straws here.