Caanoo / WIZ Wiz Panic : Black Screen Or Screen Freezing


ulula

Still Fresh
Joined
Jan 9, 2009
Messages
41
Age
41
Location
amiens
I just try to run a sample application that have just compile.
i rename it "sdl_sample.gpe" to be visible in the launcher but when i run it my WIZ freeze (black screen).
May be i do something wrong in my code but when i try application like sdlquake or mame4wiz i had the same thing.

no body know a shortcut key for kill a process ?
CODE

#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif
#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif

#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define SCREEN_DEPTH 8


int main ( int argc, char** argv )
{
// initialize SDL video
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "Unable to init SDL: %s\n", SDL_GetError() );
return 1;
}

// make sure SDL cleans up before exit
atexit(SDL_Quit);

// create a new window
SDL_Surface* screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH,
SDL_HWSURFACE|SDL_DOUBLEBUF);
if ( !screen )
{
printf("Unable to set %dx%d video: %s\n",SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
return 1;
}

// load an image
SDL_Surface* bmp = SDL_LoadBMP("cb.bmp");
if (!bmp)
{
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}

// centre the bitmap on screen
SDL_Rect dstrect;
dstrect.x = (screen->w - bmp->w) / 2;
dstrect.y = (screen->h - bmp->h) / 2;

// program main loop
bool done = false;
while (!done)
{
// message processing loop
SDL_Event event;
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
case SDL_QUIT:
done = true;
break;

// check for keypresses
case SDL_KEYDOWN:
{
// exit if ESCAPE is pressed
if (event.key.keysym.sym == SDLK_ESCAPE)
done = true;
break;
}
} // end switch
} // end of message processing

// DRAWING STARTS HERE

// clear screen
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));

// draw bitmap
SDL_BlitSurface(bmp, 0, screen, &dstrect);

// DRAWING ENDS HERE

// finally, update the screen :)
SDL_Flip(screen);
} // end main loop

// free loaded bitmap
SDL_FreeSurface(bmp);

// all is well ;)
printf("Exited cleanly\n");
return 0;
}
 
Try replacing SDL_HWSURFACE|SDL_DOUBLEBUF with SDL_SWSURFACE in your call to SDL_SetVideoMode.

I know you already check the return value of SDL_SetVideoMode in case of an error, but perhaps the firmware's SDL reacts differently.
 
Alex. posted on May 18 2009 at 10:54 PM said:
Try replacing SDL_HWSURFACE|SDL_DOUBLEBUF with SDL_SWSURFACE in your call to SDL_SetVideoMode.

I know you already check the return value of SDL_SetVideoMode in case of an error, but perhaps the firmware's SDL reacts differently.
I make change like you said but screen still freezing
 
Last edited by a moderator:
I just noticed you have the values of SCREEN_WIDTH and SCREEN_HEIGHT interchanged, the SDL screen is supposed to be 320x240 not 240x320.
 
you are right.

just one last question about key.
how to handle key event ( key pad and buttons ) in SDL.
I had see in libcastor a GPIO struct that define all key code of WIZ, may be exist an GPIO like in SDL ?
 
Here's what I use:

CODE
enum Buttons {
BUTTON_UP, BUTTON_UPLEFT, BUTTON_LEFT,
BUTTON_DOWNLEFT, BUTTON_DOWN,
BUTTON_DOWNRIGHT, BUTTON_RIGHT,
BUTTON_UPRIGHT, BUTTON_START, BUTTON_SELECT,
BUTTON_L, BUTTON_R, BUTTON_A, BUTTON_B,
BUTTON_X, BUTTON_Y, BUTTON_VOLUP,
BUTTON_VOLDOWN
};

typedef struct Input {
int up, down, left, right;
int upleft, upright, downleft, downright;
int l, r;
int a, b, x, y;
int start, select;
int volup, voldown;
} Input;

// and in an input function:

Input input;
SDL_Event event;

while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_JOYBUTTONDOWN: {
switch(event.jbutton.button) {
case BUTTON_UP:
input.up = 1;
break;

// same for the other buttons
}
} break;

case SDL_JOYBUTTONUP: {
switch(event.jbutton.button) {
case BUTTON_UP:
input.up = 0;
break;

// same for the other buttons
}
} break;
}
}
 
Back
Top