gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Blank Screen Problem - Have read the FAQ

#44279 - Kris_Allen - Tue May 31, 2005 5:21 pm

Hiya,

I know this has probably been posted a lot already but I've got this blank screen problem. I've read a few other posts, and the FAQ, but still can't seem to solve the problem.

Here's my code. I've been using the headers that come with the PERN tutorial, but for the sake of pasting here I'm just plucking out the definitions that I'm using. I'm also using pretty much the same code from the tutorial.

Code:

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;

typedef volatile unsigned  char vu8;
typedef volatile unsigned  short vu16;
typedef volatile unsigned  long vu32;

#define VideoBuffer    ((u16*)0x6000000)

#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 160

#define BIT(n) (1<<(n))

#define BG0_ENABLE      BIT(0x8)
#define BG1_ENABLE      BIT(0x9)
#define BG2_ENABLE      BIT(0xA)
#define BG3_ENABLE      BIT(0xB)
#define OBJ_ENABLE      BIT(0xC)

#define SetMode(mode) REG_DISPCNT = (mode)

#define REG_DISPCNT         (*(vu32*)0x4000000)

#define RGB16(r,g,b)  ((r)|((g)<<5)|((b)<<10))

//--------------


int main() {

   unsigned char x,y; 

   SetMode(3 | BG2_ENABLE);   

   for(x = 0; x < SCREEN_WIDTH; x++) {
       for(y = 0; y < SCREEN_HEIGHT; y++) { 
           VideoBuffer [x+y*SCREEN_WIDTH] = RGB16(31,0,0);
      }
   }
   while(1) {
      
   }
 }


This is my compile batch file:

Code:

set PATH=d:\dev\gba\devkitarm\bin\
arm-elf-gcc -Wall -mthumb -mthumb-interwork -specs=gba_mb.specs test.cpp -o test.elf
arm-elf-objcopy -v -O binary test.elf test.gba
gbafix test.gba
pause


Compiling works fine, and as you can see I haven't forgotten the thumb/interwork options.

Any ideas?

Thanks,
Kris.

Edit: Well, that's odd. I switched to DevKitAdv out of curiosity and changed my batch to this:

Code:

@echo off
set PATH=d:\dev\gba\devkitadv\bin\
arm-agb-elf-gcc -Wall -mthumb -mthumb-interwork test.cpp -o test.elf
arm-agb-elf-objcopy -v -O binary test.elf test.gba
del test.elf
pause


... And now it works fine!! Why is this?

#44288 - strager - Tue May 31, 2005 5:52 pm

Use int's instead on u8's for the loop, although it doesn't relate to the question...

Change (*(vu32 *)...) to (*(vu16 *)...).

In your compiling process: That's correct, but unhealthy. I use this for DevKitAdv:
Code:

#
# MAKEFILE
#

# Variables
CC=gcc
CCFLAGS=-mthumb-interwork ${DEBUG} -DMULTIBOOT
DEBUG=
ELFFLAGS=-nostartfiles -nostdlib -Wl,-T,lnkscript -w
OBJFLAGS=-c -g -w
OBJS=crt0.o main.o

# Compiles
all: gba.gba

clean:
   rm ${OBJS} ${GBA}.elf

gba.gba: gba.elf
   objcopy -v -O binary -S ${GBA}.elf ${GBA}.gba

gba.elf: ${OBJS}
   ${CC} ${CCFLAGS} ${ELFFLAGS} -o gba.elf ${OBJS} ${LIBS}

crt0.o: crt0.s
   ${CC} ${CCFLAGS} ${OBJFLAGS} -o crt0.o crt0.s

main.o: main.c
   ${CC} ${CCFLAGS} ${OBJFLAGS} -o main.o main.c



REM
REM BATCHFILE
REM

@echo off
make
pause

gbarm.exe -v gba.gba
pause


Filelist:
Code:

(source code files).c/.s
crt0.s
gbarm.exe
Makefile
make.bat
lnkscript


Maybe you should replace gbarm with gbafix...

#44293 - Lord Graga - Tue May 31, 2005 6:41 pm

Don't use DevkitAdvance, it's outdated. Use DevkitARM instead.

#44305 - Kris_Allen - Tue May 31, 2005 7:18 pm

yeah, I would if I could get it to work

edit: strager: I've tried setting all the options to how you've specified but it still seems to do it. Anything else it could be?

#44306 - strager - Tue May 31, 2005 7:20 pm

Can you upload your compilation? I may be able to look at it in VBA.

#44307 - Kris_Allen - Tue May 31, 2005 7:28 pm

Of course. Thanks. http://kris.acsv.net/TestGame.zip

#44320 - strager - Tue May 31, 2005 8:25 pm

It seems that you are not compiling/linking your crt0 script. Make sure it is FIRST in the list of objects, or it will not work.

#44322 - Kris_Allen - Tue May 31, 2005 8:41 pm

Ahh... thanks, I didn't actually know about that. I'll have to go and learn about it