Hey there! I've been learning the basics of coding for the fx-CG50 recently and came across an error with my linking to libfxcg's display.h and keyboard.h. Here is my code:
Code:
And here is the error:
Code:
The weird thing is, the function that gives me the error, GetVRAMAddress, is declared in display.h, and before this I tried out the PrintXY variable, which is declared in the same header, and it worked without a hitch. It would also be useful to provide a solid guide to linking headers to this file properly, as before this I've only ever linked headers to solutions.
Thanks a lot,
emibudd
Code:
#include <fxcg/display.h>
#include <fxcg/keyboard.h>
void CopySprite(const color_t* palette, int x, int y, int width, int height) {
color_t *VRAM = (color_t*)GetVRAMAddress();
VRAM += LCD_WIDTH_PX * y + x;
for (int j = y; j < y + height; j++) {
for (int i = x; i < x + height; i++) {
*(VRAM++) = *(palette++);
}
VRAM += LCD_WIDTH_PX - 16;
}
}
int main() {
const color_t sprite[512] = {
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0xff64,0xff64,0x0000,0x0000,0x0000,0x0000,0xff64,0xff64,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0xff64,0xff64,0xff64,0xff64,0x0000,0x0000,0xff64,0xff64,0xff64,0xff64,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0xff64,0x194a,0x194a,0xff64,0x0000,0x0000,0xff64,0x194a,0x194a,0xff64,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x042a,0xff64,0xff64,0xff64,0x042a,0x042a,0xff64,0xff64,0xff64,0x042a,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0000,0x0000,0x0000,
0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0000,0x0000,
0x0726,0xfbb5,0xfbb5,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0xfbb5,0xfbb5,0x0726,0x0000,0x0000,
0x0726,0xfbb5,0xfbb5,0x194a,0x0726,0x0726,0x194a,0x194a,0x0726,0x0726,0x194a,0xfbb5,0xfbb5,0x0726,0x0000,0x0000,
0x042a,0x0726,0x0726,0x0726,0x194a,0x194a,0x0726,0x0726,0x194a,0x194a,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,
0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,
0x0000,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,0x0000,
0x0000,0x0000,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x0000,0x0000,0x0000,0x0000,0x0000
};
CopySprite(sprite, 16, 16, 16, 16);
int key;
while (1) GetKey(&key);
return 0;
}
And here is the error:
Code:
main.o: In function `CopySprite(unsigned short const*, int, int, int, int)':
main.cpp:(.text+0x98): undefined reference to `_GetVRAMAddress'
The weird thing is, the function that gives me the error, GetVRAMAddress, is declared in display.h, and before this I tried out the PrintXY variable, which is declared in the same header, and it worked without a hitch. It would also be useful to provide a solid guide to linking headers to this file properly, as before this I've only ever linked headers to solutions.
Thanks a lot,
emibudd