int start() { unsigned short character = 0x00; int ipc_status; message msg; int irq_set_kb = kb_subscribe_int(); int irq_set_timer = timer_subscribe_int(); int irq_set_mouse = mouse_subscribe_int(); int r; unsigned char packet[3]; unsigned short counter = 0; space_invaders_font = font_init("spaceinvader_font_transparent.bmp"); srand(1); options_load(); mouse_init(); init_state(); highscore_load(); vg_init(VBE_VIDEO_MODE); while (1) { //TODO change condition /* Get a request message. */ if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if (msg.NOTIFY_ARG & irq_set_kb) { /* keyboard interrupt */ character = kb_int_handler(); if (character != KB_2BYTE_SCODE) kb_event_handler(character); } if (msg.NOTIFY_ARG & irq_set_mouse){ /* mouse interrupt */ mouse_int_handler(counter, packet); if(packet[0] != MOUSE_ACK && (packet[0] & BIT(3))) counter++; if(counter == 3){ counter = 0; mouse_event_handler(packet); } } if (msg.NOTIFY_ARG & irq_set_timer){ /* timer interrupt */ timer_int_handler(); } break; default: break; /* no other notifications expected: do nothing */ } } else { /* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } } return 0; }
enum plugin_status plugin_start(const void* parameter) { (void)parameter; configfile_load(CONFIG_FILE_NAME, config, 1, 0); highscore_load(SCORE_FILE, highscores, NUM_SCORES); rb->lcd_clear_display(); ingame = false; while(snake_game_loop() == 0) ; configfile_save(CONFIG_FILE_NAME, config, 1, 0); highscore_save(SCORE_FILE, highscores, NUM_SCORES); return PLUGIN_OK; }
enum plugin_status plugin_start (const void *parameter) { (void) parameter; rb->srand (*rb->current_tick); /* Load HighScore if any */ highscore_load(SCORE_FILE, highscores, NUM_SCORES); #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif #ifdef HAVE_LCD_BITMAP rb->lcd_setfont (FONT_SYSFIXED); #else if (!pgfx_init(4, 2)) { rb->splash(HZ*2, "Old LCD :("); return PLUGIN_OK; } #endif /* Turn off backlight timeout */ backlight_ignore_timeout(); load_game(); resume_file = resume; while(!rockblox_loop()) { if(!resume) { int position = highscore_update(rockblox_status.score, rockblox_status.level, "", highscores, NUM_SCORES); if (position != -1) { if (position == 0) rb->splash(HZ*2, "New High Score"); highscore_show(position, highscores, NUM_SCORES, true); } } } #ifndef HAVE_LCD_BITMAP pgfx_release(); #endif /* Save user's HighScore */ highscore_save(SCORE_FILE, highscores, NUM_SCORES); backlight_use_settings(); return PLUGIN_OK; }
enum plugin_status plugin_start(const void* parameter) { (void)(parameter); /* Lets use the default font */ rb->lcd_setfont(FONT_SYSFIXED); #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif load_all_levels(); if (num_levels == 0) { rb->splash(HZ*2, "Failed loading levels!"); return PLUGIN_OK; } highscore_load(SCORE_FILE, highscores, NUM_SCORES); while(quit==0) { game_init(); if(quit) break; rb->lcd_clear_display(); frames=1; init_snake(); /*Start Game:*/ game(); } highscore_save(SCORE_FILE, highscores, NUM_SCORES); return (quit==1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED; }
int main(int argc, char **argv) { //puzzletube setup srand(time(NULL)); settings_load(); highscore_load(); //Language setup spReadPossibleLanguages("./translations/languages.txt"); spBundlePointer translation = spLoadBundle("./translations/translations.txt",1); /* //counting all hashes: spTextPointer mom = translation->firstText; int mesh[257]; memset(mesh,0,257*4); int count = 0; while (mom) { if (mom->hash >= 0 && mom->hash < 256) { mesh[mom->hash]++; } else mesh[256]++; count++; mom = mom->next; } int i,j; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j++) { printf(" %3i",mesh[i+j*16]); } printf("\n"); } printf("Invalid hash: %i\n",mesh[256]); printf("Total hash: %i\n",count);*/ settings_set_translation(translation); //sparrow3D Init //spSetDefaultWindowSize( 800, 480 ); spInitCore(); spInitNet(); spSetAffineTextureHack(0); //We don't need it :) spInitMath(); //Setup screen = spCreateDefaultWindow(); resize(screen->w,screen->h); run_splashscreen(resize); spSetCulling(0); init_music(); prepare_game_objects(1); change_music("Midnight Mediation","Nick May"); highscore_save(); init_c4a(); run_menu(resize); quit_c4a(); delete_game_objects(); spDeleteBundle(translation,0); spFontDelete(font); spFontDelete(small_font); spFontDelete(middle_font); quit_music(); spQuitNet(); spQuitCore(); return 0; }