void init_game(void) { printf("GUI Initialization...\n"); if (TTF_Init() == -1) { fprintf(stderr, "TTF Initlization error: %s\n", TTF_GetError()); exit(1); } font_small = TTF_OpenFont(IMG_PREFIX "font.ttf", 10); font_big = TTF_OpenFont(IMG_PREFIX "font.ttf", 14); if (!font_small || !font_big) { fprintf(stderr, "Unable to open TTF font: %s\n", TTF_GetError()); exit(1); } screen = window_init(); if(!screen) { fprintf(stderr, "Unable to open display. Aborting.\n"); exit(1); } SDL_EnableKeyRepeat(100, 300); sprites = sprites_init(); if(!sprites) { fprintf(stderr, "Unable to initalize sprites. Aborting.\n"); exit(1); } color_black = SDL_MapRGB(screen->format, 0, 0, 0); game_board = MySurfaceCreate(taille_carte_x() * TAILLE_CASE + 2, taille_carte_y() * TAILLE_CASE + 2); game_background = background_init(taille_carte_x(), taille_carte_y()); if(!game_background) { fprintf(stderr, "Unable to load background.\n"); exit(1); } init_jeu(&jeu); sprites = sprites_init(); nouveau_tour(&jeu); render_map(); }
int initialize_everything() { time_t ss = time(0); enigma_user::random_set_seed(ss); enigma_user::mtrandom_seed(ss); // must occur before the create/room start/game start events so that it does not override the user setting them in code enigma::game_settings_initialize(); graphicssystem_initialize(); audiosystem_initialize(); #if defined(BUILDMODE) && BUILDMODE buildmode::buildinit(); #endif event_system_initialize(); timeline_system_initialize(); input_initialize(); sprites_init(); backgrounds_init(); widget_system_initialize(); // Open the exe for resource load char exename[1025]; windowsystem_write_exename(exename); FILE* exe = fopen(exename,"rb"); if (!exe) show_error("Resource load fail: exe unopenable",0); else do { int nullhere; // Read the magic number so we know we're looking at our own data fseek(exe,-8,SEEK_END); char str_quad[4]; if (!fread(str_quad,4,1,exe) or str_quad[0] != 'r' or str_quad[1] != 'e' or str_quad[2] != 's' or str_quad[3] != '0') { printf("No resource data in exe\n"); break; } // Get where our resources are located in the module int pos; if (!fread(&pos,4,1,exe)) break; // Go to the start of the resource data fseek(exe,pos,SEEK_SET); if (!fread(&nullhere,4,1,exe)) break; if(nullhere) break; enigma::exe_loadsprs(exe); enigma::exe_loadsounds(exe); enigma::exe_loadbackgrounds(exe); enigma::exe_loadfonts(exe); #ifdef PATH_EXT_SET enigma::exe_loadpaths(exe); #endif fclose(exe); } while (false); //Load object struct enigma::objectdata_load(); //Load rooms enigma::rooms_load(); //Go to the first room if (enigma_user::room_count) enigma::game_start(); else enigma_user::window_default(); return 0; }
int main(void) { music_init(); music_play(3); u16 delay_mod = 4; u16 col_inc_cnt = 0; setup(); reset_demo: hint_val = 3; col = 0; col_off = 0; phrase_num = 0; scroll_off = 0; dscroll = 0; term_pos = 0; term_scrolling = 0; sprites_dma_simple(); term_pos = 0; VDP_setHInterrupt(0); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); // Greyscale palette for text VDP_setPaletteColor(0,0x000); VDP_setPaletteColor(1,0x444); VDP_setPaletteColor(2,0x888); VDP_setPaletteColor(3,0xEEE); VDP_setScreenWidth256(); bios_boot_demo(); VDP_setScreenWidth320(); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); awful_put_logo(8, 2); startup_stretch(); VDP_setVerticalScroll(PLAN_A, 252); VDP_setVerticalScroll(PLAN_B, 252); VDP_setHIntCounter(hint_val); SYS_setHIntCallback((_voidCallback *)h_int); volatile u8 p1 = pad_read(0); sprites_init(); col_puts40(8,0,"Computer Science House"); // Initialize background stars star stars[NUM_STARS]; u16 i = 0; for (i = 0; i < NUM_STARS; i++) { stars[i].x = i * 5; stars[i].y = 128 + i * 8; stars[i].speed = (i % 7) + 1; stars[i].offset = (3 * i) % 4; stars[i].size = (i % 4 == 0) ? ('.' + COL_FONT_VRAM_OFFSET) : (128 + '.' + COL_FONT_VRAM_OFFSET); } print_phrase(8); u16 delay = 0; u8 dir = 0; VDP_setHInterrupt(1); for (;;) { delay++; if (col_inc_cnt == 0) { col_inc_cnt = hint_val; col_off += 0x002; } else { col_inc_cnt--; } if (delay == 512) { if (phrase_num == 8) { phrase_num = 0; VDP_setHInterrupt(0); sprite_set(0, 0, 0, 0, 0, 0); sprites_dma_simple(); while (vbl_wait) { __asm__("nop"); } vbl_wait = 1; goto reset_demo; } hint_val++; if (hint_val == 10) { hint_val = 3; } delay_mod = delay_mod >> 1; if (delay_mod == 0) { delay_mod = delay_mod = 4; } VDP_setHIntCounter(hint_val); VDP_setHInterrupt(0); print_phrase(phrase_num); VDP_setHInterrupt(1); phrase_num++; delay = 0; } process_stars(&stars); while (vbl_wait) { __asm__("nop"); } VDP_setHInterrupt(0); VDP_setPaletteColor(14,palette[col]); col = col_off; vbl_wait = 1; sprites_dma_simple(); VDP_setHInterrupt(1); } return 0; }
int demo_2() { static struct tmu_td tmu_badclouds, tmu_badfactory, tmu_clearscreen; static struct tmu_vertex badclouds_src_vtx[TMU_MESH_MAXSIZE][TMU_MESH_MAXSIZE]; static struct tmu_vertex badclouds_dst_vtx[TMU_MESH_MAXSIZE][TMU_MESH_MAXSIZE]; static struct tmu_vertex badfactory_src_vtx[TMU_MESH_MAXSIZE][TMU_MESH_MAXSIZE]; static struct tmu_vertex badfactory_dst_vtx[TMU_MESH_MAXSIZE][TMU_MESH_MAXSIZE]; static short int black = 0x0000; static struct tmu_vertex src_clr_vertices[TMU_MESH_MAXSIZE][TMU_MESH_MAXSIZE]; static struct tmu_vertex dst_clr_vertices[TMU_MESH_MAXSIZE][TMU_MESH_MAXSIZE]; int quit = 0 , x = 0; //unsigned int x , y ; //unsigned short int * vga_position; //Initialization sprites_init(); sprites_load(badclouds_raw,badclouds_raw_len,0x001F,138,100,0); sprites_load(badclouds_raw,badclouds_raw_len,0x001F,138,100,1); sprites_load(badclouds_raw,badclouds_raw_len,0x001F,138,100,2); sprites_load(badclouds_raw,badclouds_raw_len,0x001F,138,100,3); sprites_load(badclouds_raw,badclouds_raw_len,0x001F,138,100,4); sprites_load(badfactory_raw,badfactory_raw_len,0x001F,100,100,0); /* debug_sprite(&sprite_data[0]); debug_sprite(&sprite_data[1]); debug_sprite(&sprite_data[2]); debug_sprite(&sprite_data[3]); debug_sprite(&sprite_data[4]); */ init_sprite(&badclouds_src_vtx[0][0] , &badclouds_dst_vtx[0][0] , &sprite_data[0]); init_sprite(&badfactory_src_vtx[0][0] , &badfactory_dst_vtx[0][0] , &sprite_data[5]); /* for ( x = 0; x <= HMESHLAST; x++) { for ( y = 0; y <= VMESHLAST; y++) { badclouds_src_vtx[x][y].x = x * 138; badclouds_src_vtx[x][y].y = y * 100; badclouds_src_vtx[x][y].x = x * 138; badclouds_src_vtx[x][y].y = y * 100; } } */ src_clr_vertices[0][0].x = 0; src_clr_vertices[0][0].y = 0; src_clr_vertices[1][0].x = 640; src_clr_vertices[1][0].y = 0; src_clr_vertices[0][1].x = 0; src_clr_vertices[0][1].y = 480; src_clr_vertices[1][1].x = 640; src_clr_vertices[1][1].y = 480; dst_clr_vertices[0][0].x = 0 - 30; dst_clr_vertices[0][0].y = 0 - 23; dst_clr_vertices[1][0].x = 640 + 30 ; dst_clr_vertices[1][0].y = 0 - 23; dst_clr_vertices[0][1].x = 0 - 30; dst_clr_vertices[0][1].y = 480 + 23; dst_clr_vertices[1][1].x = 640 + 30; dst_clr_vertices[1][1].y = 480 + 23; //tmu_clearscreen.flags = 0; tmu_badclouds.flags = TMU_CTL_CHROMAKEY; tmu_clearscreen.hmeshlast = 1; tmu_clearscreen.vmeshlast = 1; tmu_clearscreen.brightness = 60; tmu_clearscreen.chromakey = 0; tmu_clearscreen.srcmesh = &src_clr_vertices[0][0]; tmu_clearscreen.srchres = vga_hres; tmu_clearscreen.srcvres = vga_vres; tmu_clearscreen.dstmesh = &dst_clr_vertices[0][0]; tmu_clearscreen.dsthres = vga_hres; tmu_clearscreen.dstvres = vga_vres; tmu_clearscreen.profile = 0; tmu_clearscreen.callback = tmu_complete; tmu_clearscreen.user = NULL; tmu_badclouds.flags = TMU_CTL_CHROMAKEY; tmu_badclouds.hmeshlast = HMESHLAST; tmu_badclouds.vmeshlast = VMESHLAST; tmu_badclouds.brightness = 62; tmu_badclouds.chromakey = CHROMAKEY; tmu_badclouds.srcmesh = &badclouds_src_vtx[0][0]; tmu_badclouds.srchres = 138; tmu_badclouds.srcvres = 100; tmu_badclouds.dstmesh = &badclouds_dst_vtx[0][0]; tmu_badclouds.dsthres = vga_hres; tmu_badclouds.dstvres = vga_vres; tmu_badclouds.profile = 0; tmu_badclouds.callback = tmu_complete; tmu_badclouds.user = NULL; tmu_badfactory.flags = TMU_CTL_CHROMAKEY; tmu_badfactory.hmeshlast = HMESHLAST; tmu_badfactory.vmeshlast = VMESHLAST; tmu_badfactory.brightness = 62; tmu_badfactory.chromakey = CHROMAKEY; tmu_badfactory.srcmesh = &badclouds_src_vtx[0][0]; tmu_badfactory.srchres = 100; tmu_badfactory.srcvres = 100; tmu_badfactory.dstmesh = &badclouds_dst_vtx[0][0]; tmu_badfactory.dsthres = vga_hres; tmu_badfactory.dstvres = vga_vres; tmu_badfactory.profile = 0; tmu_badfactory.callback = tmu_complete; tmu_badfactory.user = NULL; x = 0; frames = 0; while(quit < 10) { tmu_clearscreen.srcfbuf = vga_lastbuffer; tmu_clearscreen.dstfbuf = vga_backbuffer; tmu_wait = 0; tmu_submit_task(&tmu_clearscreen); while(!tmu_wait); //update_sprite(tmu_badclouds.dstmesh ,&sprite_data[x/20], 320 , 240 , frames); if (x/40 == 5) { init_sprite(tmu_badfactory.srcmesh,tmu_badclouds.dstmesh ,&sprite_data[x/40]); scale_sprite(tmu_badfactory.dstmesh , (100 + COS[frames])/10 , (100 + COS[frames])/10 ); rotate_sprite(tmu_badfactory.dstmesh , frames); move_sprite(tmu_badfactory.dstmesh , 320 , 240); tmu_badfactory.srcfbuf = sprite_data[x/40].data; tmu_badfactory.dstfbuf = vga_backbuffer; } else { init_sprite(tmu_badclouds.srcmesh,tmu_badclouds.dstmesh ,&sprite_data[x/40]); scale_sprite(tmu_badclouds.dstmesh , (100 + COS[frames])/10 , (100 + COS[frames])/10 ); rotate_sprite(tmu_badclouds.dstmesh , frames); move_sprite(tmu_badclouds.dstmesh , 320 , 240); tmu_badclouds.srcfbuf = sprite_data[x/40].data; tmu_badclouds.dstfbuf = vga_backbuffer; } /* tmu_clearscreen.srcfbuf = &black; tmu_clearscreen.dstfbuf = vga_backbuffer; tmu_wait = 0; tmu_submit_task(&tmu_clearscreen); while(!tmu_wait); */ tmu_wait = 0; tmu_submit_task(&tmu_badclouds); while(!tmu_wait); flush_bridge_cache(); vga_swap_buffers(); // demo_sleep(10); x += 1; frames+=5; if (frames > 360) frames = frames - 360; if (x == 240) {x = 0;quit++;} } return 0; }