MPoupe wrote:
Add this function ( I found it somewhere, it should be on 1 line):
color_t* GetVRAMAddress() { __asm__("mov.l syscall_adress, r2\n" "mov.l getVRAM, r0\n" "jmp @r2\n" "nop\n" "syscall_adress: .long 0x80020070\n" "getVRAM: .long 0x01E6"); }
And remove const from the line:
const color_t* VRAM = GetVRAMAdress();
Removing const and not adding that line fixes one of the errors, so I get this:
Code: C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp: In function 'void CopySprite(const color_t*, int, int, int, int)':
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:7:32: error: 'GetVRAMAdress' was not declared in this scope
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp: In function 'int main()':
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:22:22: warning: unused variable 'frog1' [-Wunused-variable]
However, adding that lines causes a bunch more to pop up:
Code: C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp: In function 'color_t* GetVRAMAddress()':
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:4:25: error: new declaration 'color_t* GetVRAMAddress()'
C:/Users/emili/Documents/PrizmSDK-0.3/include/fxcg/display.h:28:7: error: ambiguates old declaration 'void* GetVRAMAddress()'
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:4:171: warning: no return statement in function returning non-void [-Wreturn-type]
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp: In function 'void CopySprite(const color_t*, int, int, int, int)':
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:7:32: error: 'GetVRAMAdress' was not declared in this scope
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp: In function 'int main()':
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:22:22: warning: unused variable 'frog1' [-Wunused-variable]
By the way, this is what my code looks like now:
Code: #include <fxcg/display.h>
#include <fxcg/keyboard.h>
color_t* GetVRAMAddress() { __asm__("mov.l syscall_adress, r2\n" "mov.l getVRAM, r0\n" "jmp @r2\n" "nop\n" "syscall_adress: .long 0x80020070\n" "getVRAM: .long 0x01E6"); }
void CopySprite(const color_t* palette, int x, int y, int width, int height) {
color_t* VRAM = GetVRAMAdress();
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_palette[6] = { 0x0000, 0xff64, 0x194a, 0x042a, 0x0726, 0xfbb5 };
const unsigned char frog1[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,
0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,
0,0,1,2,2,1,0,0,1,2,2,1,0,0,0,0,
0,0,3,1,1,1,3,3,1,1,1,3,0,0,0,0,
0,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,
4,5,5,4,4,4,4,4,4,4,4,5,5,4,0,0,
4,5,5,2,4,4,2,2,4,4,2,5,5,4,0,0,
3,4,4,4,2,2,4,4,2,2,4,4,4,3,0,0,
3,4,4,4,4,4,4,4,4,4,4,4,4,3,0,0,
0,3,4,4,4,4,4,4,4,4,4,4,3,0,0,0,
0,0,3,4,4,4,4,4,4,4,4,3,0,0,0,0,
0,0,0,3,3,3,3,3,3,3,3,0,0,0,0,0
};
CopySprite(sprite_palette, 16, 16, 16, 16);
int key;
while (1) GetKey(&key);
return 0;
}