Welcome! Log In Create A New Profile

Advanced

GRRLIB - Nothing, Just Black Screen *SOLVED*

Posted by LordAshes 
GRRLIB - Nothing, Just Black Screen *SOLVED*
April 01, 2010 02:37PM
Update:

I reshuffled the code and changed some of the statics and suddnly it started working.

Original Post:

I am working on a generic project. The program spreds over 4 main files:

"main.c" defines some higher level object functions and the main loop
"Object.c" defines low level object functions (implemented with a Linked List)
"Support.h" defines project specific code such as textures and actions to take each frame, on collision, on creation on destruction, etc.
"SupportVar.h" defines some project specific variables.

Originally I had all of the stuff being loaded inside the main function (of the main.c file). However, I did not like this functions within function within functions approach and it was preventing me from getting a critical part of the code working (two functions that call each other) so I statically prototyped the functions and moved them outside the main function.

The problem is that now the code compiles but all I get is a black screen. The only warning during compile is about a couple variables and one function which currently are not used (which, at the moment, is true). Before when I had the functions within functions approach, I was able to get the objects all to work correctly and display. I have changed the background color that GRRLIB uses (in the main loop) to Red and I still only get a Black screen. This tells me that the problem is not with displaying my objects but that the program does not even make it through one frame of mail loop code (i.e. does not reach the first render). I tried to add file access to record the steps through the main code to a log file but it either did not work or the main loop was never executed (i.e. I did not get anything in the log file). I don't think the program is even making it into the main loop because pressing the Home button does not seem to execute the exit code.

All the files can be download in one zip file (called Source.zip) at:

[www.mediafire.com]

I am guessing I made some kind of a stupid mistake somewhere which is causing the program to lock up or never run the main loop, but I can't seem to find it. Maybe a problem with the static prototypes or definitions?

Can anyone *please* help?

Here is an abridged version of the main.c file:

#include
#include
#include
#include
#include
#include
#include "gfx/font.h"

// Include Object Structure And Object Functions

#include "objects.c"

// Include Variables Needed For Project Specific Code

LLIST *Obj;

static int internal_wiimote = WPAD_CHAN_0; // Indicates which Wiimote is being read
static WPADData *wiimote_data[4]; // Holds Wiimote data for each controller
static GRRLIB_texImg *internal_font; // Internal Font Texture

// Include Project Specific Code

#include "SupportVars.h"
#include "Support.h"

// Include Function Prototypes

static u8 CalculateFrameRate();
static bool obj_vs_obj_collision(LLIST *Obj1, LLIST *Obj2);
static void obj_frame_code(LLIST *Current);
static void obj_collision(LLIST *Current);
static void obj_move(LLIST *Current);
static void obj_draw(LLIST *Current);

// Include Function Defenition

// This function checks for rough collisions

static bool obj_vs_obj_collision(LLIST *Obj1, LLIST *Obj2)
{
...
}

// This function perfoms all the frame code for each object

static void obj_frame_code(LLIST *Current)
{
...
}

// This function perfoms full collision detection for all objects which have collision code

static void obj_collision(LLIST *Current)
{
...
}

// This function moves all the objects by their horizontal and vertical movement

static void obj_move(LLIST *Current)
{
...
}

// This function draws all the objects according to their layers
// (higher layers are drawn first so that lower layers will be drawn on top)

static void obj_draw(LLIST *Current)
{
...
}

int main() {

// This function performs frame and wiimote code

GRRLIB_Init();
WPAD_SetVRes(0, 640, 480);
internal_font = GRRLIB_LoadTexture(font);
GRRLIB_InitTileSet(internal_font, 16, 16, 32);
init_all_textures();
// Create First Entry in LinkedList (Used for Background)
Obj = (LLIST *) malloc(sizeof(LLIST));
Obj->ID = 0;
Obj->type = 0;
*Obj->active = default_pause_state;
Obj->layer = 999;
Obj->animated = 0;
...
Obj->x = 1.0;
Obj->y = 1.0;
Obj->dx = 0.0;
Obj->dy = 0.0;
Obj->angle = 0.0;
Obj->image = 1;
Obj->prev = NULL;
Obj->next = NULL;

room_setup(INITIAL_ROOM);
WPAD_Init();

...

while(1)
{
WPAD_ScanPads();
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) {break;}
GRRLIB_FillScreen(GRRLIB_RED);

...

obj_collision(Obj);
obj_frame_code(Obj);
obj_move(Obj);
obj_draw(Obj);
GRRLIB_Render();
}

// Free Font Texture
GRRLIB_FreeTexture(internal_font);
// Free All Images Textures
free_all_textures();
// Destory Linked List Freeing Memory
obj_destroy_all(Obj);
// Free initial LInked List object
free(Obj);
// Be a good boy, clear the memory allocated by GRRLIB
GRRLIB_Exit();
// Exit
return 0;
}


Like I said, the Linked List code worked fine before. Same with the Support.h code. So either during the transition to static functions outside main function they stopped working (causing a hang) or I accidentally deleted something that I should not have.



Edited 2 time(s). Last edit at 04/03/2010 11:20AM by LordAshes.
Sorry, only registered users may post in this forum.

Click here to login