#11014 - blasty - Tue Sep 23, 2003 2:04 pm
Hi,
Today I just started programming for the GBA (in C)
I tried to write a basical program which loads a sprite into video memory (Mode 4)
It compiles fine but when I run my rom with VisualBoyadvance it displays two lines of pixels that change constantly and not my cool sprite :(
spritedata has been generated using an utillitie from gbadev.org
my code is:
woei.h holds my sprite and palette data.
Any suggestions?
Today I just started programming for the GBA (in C)
I tried to write a basical program which loads a sprite into video memory (Mode 4)
It compiles fine but when I run my rom with VisualBoyadvance it displays two lines of pixels that change constantly and not my cool sprite :(
spritedata has been generated using an utillitie from gbadev.org
my code is:
Code: |
#include"gba_types.h" #include"gba_mem.h" #include"gba_const.h" #include "woei.h" #ifdef MULTIBOOT volatile const u8 __gba_multiboot; // crt0.o const for multiboot mode #endif #define VIDC_BASE 0x4000000 #define DISPCNT *(u32*)(VIDC_BASE) #define DISP_BG2 0x400 #define OBJ_MAP_2D 0x0 #define OBJ_MAP_1D 0x40 #define VRAM_BASE 0x6000000 // Hier start et Video RAM :) #define BG_PAL 0x5000000 // BG Palette // macro om DISPCNT mee te berekenen #define DISP_MODE(n) (n & 7) u16* VidRam = (u16 *)VRAM_BASE; u16* Palette = (u16*)BG_PAL; void plotpixel(int x, int y, unsigned short int c) { VidRam[y + 120 + x] = c; } int AgbMain() { int y, x, i; DISPCNT = DISP_MODE(4)|DISP_BG2; for (i = 0; i < 256; i++) Palette[i] = kleurtjes[i]; for(y = 0; y < 160; y++) { for (x = 0; x < 120; x++) { plotpixel(x,y,Data[y*120+x]); } } return 0; } |
woei.h holds my sprite and palette data.
Any suggestions?