void global_flush_tlb(void) { LIST_HEAD(l); struct page *pg, *next; BUG_ON(irqs_disabled()); spin_lock_irq(&cpa_lock); list_splice_init(&df_list, &l); spin_unlock_irq(&cpa_lock); flush_map(); list_for_each_entry_safe(pg, next, &l, lru) __free_page(pg); }
int main(int argc, char *argv[]){ Spawn *player; InterfaceData idata = {0, NULL, -1, NULL, 1}; SDL_Event event; int num_tiles = OUTPUT_IN_GLYPHS_X * OUTPUT_IN_GLYPHS_Y, i; /*SDL anmachen*/ if(SDL_Init(SDL_INIT_VIDEO)) return EXIT_FAILURE; SDL_EnableKeyRepeat(200, 50); /*Karte laden*/ if(argc==2) map=load_map(argv[1]); else{ fprintf(stderr,"Kartennamen angeben\n"); return EXIT_FAILURE; } if(map == NULL) { fprintf(stderr,"Fehler beim Laden der Karte\n"); return EXIT_FAILURE; } player = get_player_spawn(map); if(player==NULL){ fprintf(stderr, "Kein Spieler auf der Karte\n"); return EXIT_FAILURE; } /*Map zeichnen*/ /* Ausgabepuffer initialisieren */ buf = (BufferTile*)ex_malloc(sizeof(BufferTile) * num_tiles); for(i = 0; i < num_tiles; ++i) { BufferTile bt = {' ', 0x00000000}; buf[i] = bt; } output_init(OUTPUT_IN_GLYPHS_X, OUTPUT_IN_GLYPHS_Y, map->name); explore_area(player, map); create_output_buffer(map, buf, num_tiles); get_interface_data(map, &idata); output_draw(buf, num_tiles, &idata); /*Eingabeloop*/ int quit=0; KeyAction current_action = INVALID; while(SDL_WaitEvent(&event)){ if(event.type == SDL_KEYDOWN) { current_action = get_action(event.key.keysym.sym); /*bei Escape beenden*/ if(event.key.keysym.sym == SDLK_ESCAPE){ quit=1; break; } if(current_action != INVALID) { process_event(current_action, map); } create_output_buffer(map, buf, num_tiles); get_interface_data(map, &idata); output_draw(buf, num_tiles, &idata); } else if(event.type == SDL_QUIT) { quit=1; break; } SDL_Delay(1); /*Affe tot => Klappe zu*/ if(player->hp<=0){ game_over(0); break; } /* Ende erreicht */ if(map->finished) { game_over(1); break; } } if(!quit){ while(SDL_WaitEvent(&event)){ /*bei Escape beenden*/ if(event.type == SDL_QUIT || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) { break; } SDL_Delay(1); } } free(buf); flush_map(map); free(idata.message); free(idata.item_name); output_close(); SDL_Quit(); return EXIT_SUCCESS; }