Changeset 134 for abuse/trunk/src/game.cpp
- Timestamp:
- Apr 10, 2008, 11:08:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/game.cpp
r129 r134 29 29 #include "ability.hpp" 30 30 #include "cache.hpp" 31 #include "loader.hpp"32 31 #include "lisp.hpp" 33 32 #include "jrand.hpp" … … 1219 1218 void do_title() 1220 1219 { 1221 if(cdc_logo != -1) 1222 { 1223 if(sound_avail & MUSIC_INITIALIZED) 1224 { 1225 if(current_song) 1220 if(cdc_logo == -1) 1221 return; 1222 1223 if(sound_avail & MUSIC_INITIALIZED) 1224 { 1225 if(current_song) 1226 { 1227 current_song->stop(); 1228 delete current_song; 1229 } 1230 current_song = new song("music/intro.hmi"); 1231 current_song->play(music_volume); 1232 } 1233 1234 void *logo_snd = symbol_value(make_find_symbol("LOGO_SND")); 1235 1236 if(DEFINEDP(logo_snd) && (sound_avail & SFX_INITIALIZED)) 1237 cache.sfx(lnumber_value(logo_snd))->play(sfx_volume); 1238 1239 // This must be a dynamic allocated image because if it 1240 // is not and the window gets closed during do_title, then 1241 // exit() will try to delete (through the desctructor of 1242 // image_list in image.cpp) the image on the stack -> boom. 1243 image *blank = new image(2, 2); 1244 blank->clear(); 1245 wm->set_mouse_shape(blank->copy(), 0, 0); // hide mouse 1246 delete blank; 1247 fade_in(cache.img(cdc_logo), 32); 1248 1249 milli_wait(400); 1250 1251 void *space_snd = symbol_value(make_find_symbol("SPACE_SND")); 1252 1253 fade_out(32); 1254 milli_wait(100); 1255 1256 int i; 1257 char *str = lstring_value(eval(make_find_symbol("plot_start"))); 1258 1259 bFILE *fp = open_file("art/smoke.spe", "rb"); 1260 if(!fp->open_failure()) 1261 { 1262 spec_directory sd(fp); 1263 palette *old_pal = pal; 1264 pal = new palette(sd.find(SPEC_PALETTE), fp); 1265 pal->shift(1); 1266 1267 image *gray = new image(sd.find("gray_pict"), fp); 1268 image *smoke[5]; 1269 1270 char nm[20]; 1271 for(i = 0; i < 5; i++) 1272 { 1273 sprintf(nm, "smoke%04d.pcx", i + 1); 1274 smoke[i] = new image(sd.find(nm), fp); 1275 } 1276 1277 screen->clear(); 1278 pal->load(); 1279 1280 int dx = (xres + 1) / 2 - gray->width() / 2, dy = (yres + 1) / 2 - gray->height() / 2; 1281 gray->put_image(screen, dx, dy); 1282 smoke[0]->put_image(screen, dx + 24, dy + 5); 1283 1284 fade_in(NULL, 16); 1285 uint8_t cmap[32]; 1286 for(i = 0; i < 32; i++) 1287 cmap[i] = pal->find_closest(i * 256 / 32, i * 256 / 32, i * 256 / 32); 1288 1289 event ev; 1290 ev.type = EV_SPURIOUS; 1291 time_marker start; 1292 1293 for(i = 0; i < 320 && (ev.type != EV_KEY && ev.type != EV_MOUSE_BUTTON); i++) 1294 { 1295 gray->put_image(screen, dx, dy); 1296 smoke[i % 5]->put_image(screen, dx + 24, dy + 5); 1297 text_draw(205 - i, dx + 15, dy, dx + 320 - 15, dy + 199, str, wm->font(), cmap, wm->bright_color()); 1298 wm->flush_screen(); 1299 time_marker now; 1300 1301 while(now.diff_time(&start) < 0.18) 1226 1302 { 1227 current_song->stop();1228 delete current_song;1303 milli_wait(20); // ECS - Added the wait, so CPU utilization stays low during the story 1304 now.get_time(); 1229 1305 } 1230 current_song = new song("music/intro.hmi"); 1231 current_song->play(music_volume); 1232 } 1233 1234 void *logo_snd = symbol_value(make_find_symbol("LOGO_SND")); 1235 1236 if(DEFINEDP(logo_snd) && (sound_avail & SFX_INITIALIZED)) 1237 cache.sfx(lnumber_value(logo_snd))->play(sfx_volume); 1238 1239 // This must be a dynamic allocated image because if it 1240 // is not and the window gets closed during do_title, then 1241 // exit() will try to delete (through the desctructor of 1242 // image_list in image.cpp) the image on the stack -> boom. 1243 image *blank = new image(2, 2); 1244 blank->clear(); 1245 wm->set_mouse_shape(blank->copy(), 0, 0); // hide mouse 1246 delete blank; 1247 fade_in(cache.img(cdc_logo), 32); 1248 1249 milli_wait(400); 1250 1251 void *space_snd = symbol_value(make_find_symbol("SPACE_SND")); 1252 1253 fade_out(32); 1254 milli_wait(100); 1255 1256 int i; 1257 char *str = lstring_value(eval(make_find_symbol("plot_start"))); 1258 1259 bFILE *fp = open_file("art/smoke.spe", "rb"); 1260 if(!fp->open_failure()) 1261 { 1262 spec_directory sd(fp); 1263 palette *old_pal = pal; 1264 pal = new palette(sd.find(SPEC_PALETTE), fp); 1265 pal->shift(1); 1266 1267 image *gray = new image(sd.find("gray_pict"), fp); 1268 image *smoke[5]; 1269 1270 char nm[20]; 1271 for(i = 0; i < 5; i++) 1306 1307 start.get_time(); 1308 1309 while(wm->event_waiting() && ev.type != EV_KEY) 1272 1310 { 1273 sprintf(nm, "smoke%04d.pcx", i + 1); 1274 smoke[i] = new image(sd.find(nm), fp); 1311 wm->get_event(ev); 1275 1312 } 1276 1277 screen->clear(); 1278 pal->load(); 1279 1280 int dx = (xres + 1) / 2 - gray->width() / 2, dy = (yres + 1) / 2 - gray->height() / 2; 1281 gray->put_image(screen, dx, dy); 1282 smoke[0]->put_image(screen, dx + 24, dy + 5); 1283 1284 fade_in(NULL, 16); 1285 uint8_t cmap[32]; 1286 for(i = 0; i < 32; i++) 1287 cmap[i] = pal->find_closest(i * 256 / 32, i * 256 / 32, i * 256 / 32); 1288 1289 event ev; 1290 ev.type = EV_SPURIOUS; 1291 time_marker start; 1292 1293 for(i = 0; i < 320 && (ev.type != EV_KEY && ev.type != EV_MOUSE_BUTTON); i++) 1313 if((i % 5) == 0 && DEFINEDP(space_snd) && (sound_avail & SFX_INITIALIZED)) 1294 1314 { 1295 gray->put_image(screen, dx, dy); 1296 smoke[i % 5]->put_image(screen, dx + 24, dy + 5); 1297 text_draw(205 - i, dx + 15, dy, dx + 320 - 15, dy + 199, str, wm->font(), cmap, wm->bright_color()); 1298 wm->flush_screen(); 1299 time_marker now; 1300 1301 while(now.diff_time(&start) < 0.18) 1302 { 1303 milli_wait(20); // ECS - Added the wait, so CPU utilization stays low during the story 1304 now.get_time(); 1305 } 1306 1307 start.get_time(); 1308 1309 while(wm->event_waiting() && ev.type != EV_KEY) 1310 { 1311 wm->get_event(ev); 1312 } 1313 if((i % 5) == 0 && DEFINEDP(space_snd) && (sound_avail & SFX_INITIALIZED)) 1314 { 1315 cache.sfx(lnumber_value(space_snd))->play(sfx_volume * 90 / 127); 1316 } 1315 cache.sfx(lnumber_value(space_snd))->play(sfx_volume * 90 / 127); 1317 1316 } 1318 1319 the_game->reset_keymap(); 1320 1321 fade_out(16); 1322 1323 for(i = 0; i < 5; i++) 1324 delete smoke[i];1325 delete gray;1326 delete pal;1327 pal = old_pal;1328 }1329 delete fp;1330 1331 if(title_screen >= 0) 1332 fade_in(cache.img(title_screen), 32);1333 }1317 } 1318 1319 the_game->reset_keymap(); 1320 1321 fade_out(16); 1322 1323 for(i = 0; i < 5; i++) 1324 delete smoke[i]; 1325 delete gray; 1326 delete pal; 1327 pal = old_pal; 1328 } 1329 delete fp; 1330 1331 if(title_screen >= 0) 1332 fade_in(cache.img(title_screen), 32); 1334 1333 } 1335 1334
Note: See TracChangeset
for help on using the changeset viewer.