tuxanci2-engine
Game engine for tuxanci2
Log | Files | Refs | README | LICENSE

main.c (810B)


      1 #include "audio.h"
      2 #include "ft2.h"
      3 #include "display.h"
      4 #include "fb.h"
      5 #include "api.h"
      6 #include "screen.h"
      7 #include "vm.h"
      8 #include "tab.h"
      9 
     10 void ta_main_destroy(void) {
     11 	int32_t exit_code = ta_vm_exit_code();
     12 
     13 	ta_ft2_destroy();
     14 	ta_screen_destroy();
     15 	ta_vm_unload();
     16 	ta_tab_unload();
     17 	ta_display_deinit();
     18 
     19 	ta_exit(exit_code);
     20 }
     21 
     22 bool ta_main_update(void) {
     23 	ta_audio_update();
     24 
     25 	bool drawn = ta_screen_update();
     26 
     27 	if (ta_vm_exec_pending()) {
     28 		ta_vm_exec_apply();
     29 	}
     30 
     31 	if (!ta_vm_running) {
     32 		ta_main_destroy();
     33 	}
     34 
     35 	if (!drawn) {
     36 		return false;
     37 	}
     38 
     39 	ta_fb_swap(&ta_fb);
     40 
     41 	return true;
     42 }
     43 
     44 void ta_main_init(void) {
     45 	if (!ta_display_init() || (!ta_display->sprite_mode && !ta_fb_init(ta_display))) {
     46 		ta_exit(1);
     47 	}
     48 
     49 	ta_screen_init();
     50 
     51 	if (!ta_vm_load_tab("game/tuxanci2.tab")) {
     52 		ta_exit(1);
     53 	}
     54 }