#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
+#include "SDL_getenv.h"
#include "graphics.h"
#include "mancala.h"
// the hildon-game-wrapper context
HgwContext *hgw_context = NULL;
+// for debugging, example:
+
+// rmz_debug(g_strdup_printf("play step 2: SDL_AUDIODRIVER: %s",
+// my_sdl_audiodrv)
+// );
+
+// void rmz_debug (char *msg){
+// FILE *pFile;
+//
+// pFile = fopen ("/home/rzingg/mancala.debug", "a");
+// if (pFile) {
+// fprintf (pFile, "rmz_debug: %s \n", msg);
+// fclose (pFile);
+// }
+// }
+
void sdl_clean_up(){
int i = 0;
}
int play() {
+
+// Scratchbox needs different SDL_AudiDriver env
+ #if __i386__
+ putenv("SDL_AUDIODRIVER=alsa") ;
+ #endif /* __i386__ */
SDL_Rect board_rect, title_rect, exit_rect;
SDL_Color font_color;
}
//Initialize SDL_mixer
-
if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
+ // if( Mix_OpenAudio(22050, (Uint16)AUDIO_U8, 2, 256 ) == -1 )
{
fprintf(stderr, "Unable to initialize Mix_OpenAudio: %s\n",
SDL_GetError());
return 1;
}
-
/* Load our images... PNGs now, maybe XPMs later */
sprintf(tile_path, "%s/tile.png", RES_PATH);
if ((tile = LoadRes(tile_path)) == NULL) {
sdl_clean_up();
return 1;
}
-
+ SDL_ShowCursor(SDL_DISABLE);
/* define the font color fot the exit text */
font_color_exit.r = 255;
font_color_exit.r = 255;
font_color_exit.r = 255;
-
-
if (!(exit_text = TTF_RenderText_Blended(home_font, "EXIT",
font_color_exit))) {
fprintf(stderr, "SDL_ttf: %s\n", TTF_GetError());
redraw_board = 0;
}
+ hgw_msg_compat_receive(hgw_context, 0);
+
}
SDL_Delay(DELAY_AI);
+
sdl_clean_up();
return 0;
int main(int argc, char **argv) {
-
- fprintf(stderr, "mancala main loop\n");
-// #if HGW_FUNC
+
hgw_context = hgw_context_compat_init(argc, argv);
if (!hgw_context) {
fprintf(stderr, "Cannot init hildon-games-startup!\n");
return 0;
}
+
hgw_compat_set_cb_exit(hgw_context, exit_callback);
hgw_compat_set_cb_quit(hgw_context, quit_callback);
- hgw_compat_set_cb_flush(hgw_context, flush_callback);
+ hgw_compat_set_cb_flush(hgw_context, flush_callback);
if(!hgw_context_compat_check(hgw_context)) return 0;
-
+
/* hildon-games-wrapper part */
hgw_msg_compat_receive(hgw_context, 0);
usleep(100);
-// #endif
+
// Main game
play();
-// #if HGW_FUNC
hgw_context_compat_destroy_deinit(hgw_context);
-// #endif
+ hgw_context_destroy(hgw_context);
return 0;
}