void CK_InitGame() { // Can't do much without memory! MM_Startup(); //TODO: Get filenames/etc from config/episode // Load the core datafiles CA_Startup(); // Setup saved games handling US_Setup(); // Set a few Menu Callbacks // TODO: Finish this! US_SetMenuFunctionPointers(&CK_LoadGame, &CK_SaveGame, &CK_ExitMenu); // Set ID engine Callbacks ca_beginCacheBox = CK_BeginCacheBox; ca_updateCacheBox = CK_UpdateCacheBox; ca_finishCacheBox = CK_FinishCacheBox; // Mark some chunks we'll need. CA_ClearMarks(); CA_MarkGrChunk(FON_MAINFONT); CA_MarkGrChunk(ca_gfxInfoE.offTiles8); CA_MarkGrChunk(ca_gfxInfoE.offTiles8m); CA_MarkGrChunk(MPIC_STATUSLEFT); CA_MarkGrChunk(MPIC_STATUSRIGHT); CA_MarkGrChunk(PIC_TITLESCREEN); // Moved from CA_Startup CA_CacheMarks(0); // Lock them chunks in memory. CA_LockGrChunk(FON_MAINFONT); MM_SetLock(&ca_graphChunks[ca_gfxInfoE.offTiles8], true); MM_SetLock(&ca_graphChunks[ca_gfxInfoE.offTiles8m], true); MM_SetLock(&ca_graphChunks[MPIC_STATUSLEFT], true); MM_SetLock(&ca_graphChunks[MPIC_STATUSRIGHT], true); // Compile the actions CK_ACT_SetupFunctions(); CK_KeenSetupFunctions(); CK_OBJ_SetupFunctions(); CK_Map_SetupFunctions(); CK_Misc_SetupFunctions(); ck_currentEpisode->setupFunctions(); CK_ACT_LoadActions("ACTION.EXT"); // Setup the screen VL_InitScreen(); // TODO: Palette initialization should be done in the terminator code VL_SetDefaultPalette(); // Setup input IN_Startup(); // Setup audio SD_Startup(); US_Startup(); // Wolf loads fonts here, but we do it in CA_Startup()? RF_Startup(); VL_ColorBorder(3); VL_ClearScreen(0); VL_Present(); // Create a surface for the dropdown menu ck_statusSurface = VL_CreateSurface(STATUS_W+64, STATUS_H+16); }
void Victory (void) { #ifndef SPEARDEMO int32_t sec; int i, min, kr, sr, tr, x; char tempstr[8]; #define RATIOX 6 #define RATIOY 14 #define TIMEX 14 #define TIMEY 8 #ifdef SPEAR CA_CacheGrChunk (BJCOLLAPSE1PIC); CA_CacheGrChunk (BJCOLLAPSE2PIC); CA_CacheGrChunk (BJCOLLAPSE3PIC); CA_CacheGrChunk (BJCOLLAPSE4PIC); VWB_Bar (0, 0, 320, 200, VIEWCOLOR); VWB_DrawPic (124, 44, BJCOLLAPSE1PIC); VW_UpdateScreen (); VW_FadeIn (); VW_WaitVBL (2 * 70); VWB_DrawPic (124, 44, BJCOLLAPSE2PIC); VW_UpdateScreen (); VW_WaitVBL (105); VWB_DrawPic (124, 44, BJCOLLAPSE3PIC); VW_UpdateScreen (); VW_WaitVBL (105); VWB_DrawPic (124, 44, BJCOLLAPSE4PIC); VW_UpdateScreen (); VW_WaitVBL (3 * 70); UNCACHEGRCHUNK (BJCOLLAPSE1PIC); UNCACHEGRCHUNK (BJCOLLAPSE2PIC); UNCACHEGRCHUNK (BJCOLLAPSE3PIC); UNCACHEGRCHUNK (BJCOLLAPSE4PIC); VL_FadeOut (0, 255, 0, 17, 17, 5); #endif ClearSplitVWB (); CacheLump (LEVELEND_LUMP_START, LEVELEND_LUMP_END); CA_CacheGrChunk (STARTFONT); #ifndef SPEAR CA_CacheGrChunk (C_TIMECODEPIC); #endif VWB_Bar (0, 0, 320, screenHeight / STATUSLINES + 1, VIEWCOLOR); if (bordercol != VIEWCOLOR) DrawStatusBorder (VIEWCOLOR); #ifdef JAPAN #ifndef JAPDEMO CA_CacheGrChunk (C_ENDRATIOSPIC); VWB_DrawPic (0, 0, C_ENDRATIOSPIC); UNCACHEGRCHUNK (C_ENDRATIOSPIC); #endif #else Write (18, 2, STR_YOUWIN); Write (TIMEX, TIMEY - 2, STR_TOTALTIME); Write (12, RATIOY - 2, "averages"); #ifdef SPANISH Write (RATIOX + 2, RATIOY, STR_RATKILL); Write (RATIOX + 2, RATIOY + 2, STR_RATSECRET); Write (RATIOX + 2, RATIOY + 4, STR_RATTREASURE); #else Write (RATIOX + 8, RATIOY, STR_RATKILL); Write (RATIOX + 4, RATIOY + 2, STR_RATSECRET); Write (RATIOX, RATIOY + 4, STR_RATTREASURE); #endif #endif #ifndef JAPDEMO VWB_DrawPic (8, 4, L_BJWINSPIC); #endif for (kr = sr = tr = sec = i = 0; i < LRpack; i++) { sec += LevelRatios[i].time; kr += LevelRatios[i].kill; sr += LevelRatios[i].secret; tr += LevelRatios[i].treasure; } #ifndef SPEAR kr /= LRpack; sr /= LRpack; tr /= LRpack; #else kr /= 14; sr /= 14; tr /= 14; #endif min = sec / 60; sec %= 60; if (min > 99) min = sec = 99; i = TIMEX * 8 + 1; VWB_DrawPic (i, TIMEY * 8, L_NUM0PIC + (min / 10)); i += 2 * 8; VWB_DrawPic (i, TIMEY * 8, L_NUM0PIC + (min % 10)); i += 2 * 8; Write (i / 8, TIMEY, ":"); i += 1 * 8; VWB_DrawPic (i, TIMEY * 8, L_NUM0PIC + (sec / 10)); i += 2 * 8; VWB_DrawPic (i, TIMEY * 8, L_NUM0PIC + (sec % 10)); VW_UpdateScreen (); itoa (kr, tempstr, 10); x = RATIOX + 24 - (int) strlen(tempstr) * 2; Write (x, RATIOY, tempstr); itoa (sr, tempstr, 10); x = RATIOX + 24 - (int) strlen(tempstr) * 2; Write (x, RATIOY + 2, tempstr); itoa (tr, tempstr, 10); x = RATIOX + 24 - (int) strlen(tempstr) * 2; Write (x, RATIOY + 4, tempstr); #ifndef SPANISH #ifndef UPLOAD #ifndef SPEAR // // TOTAL TIME VERIFICATION CODE // if (gamestate.difficulty >= gd_medium) { VWB_DrawPic (30 * 8, TIMEY * 8, C_TIMECODEPIC); fontnumber = 0; fontcolor = READHCOLOR; PrintX = 30 * 8 - 3; PrintY = TIMEY * 8 + 8; PrintX += 4; tempstr[0] = (((min / 10) ^ (min % 10)) ^ 0xa) + 'A'; tempstr[1] = (int) ((((sec / 10) ^ (sec % 10)) ^ 0xa) + 'A'); tempstr[2] = (tempstr[0] ^ tempstr[1]) + 'A'; tempstr[3] = 0; US_Print (tempstr); } #endif #endif #endif fontnumber = 1; VW_UpdateScreen (); VW_FadeIn (); IN_Ack (); VW_FadeOut (); if(screenHeight % 200 != 0) VL_ClearScreen(0); #ifndef SPEAR UNCACHEGRCHUNK (C_TIMECODEPIC); #endif UnCacheLump (LEVELEND_LUMP_START, LEVELEND_LUMP_END); #ifndef SPEAR EndText (); #else EndSpear (); #endif #endif // SPEARDEMO }
static int DemoLoop(unsigned id) { static int LastDemo = 0; switch (id) { case JE_NONE: /* check for launch from ted */ if (param_tedlevel != -1) { param_nowait = true; EnableEndGameMenuItem(); NewGame(param_difficulty,0); gamestate.episode = 0; gamestate.mapon = param_tedlevel; #ifndef SPEAR gamestate.episode = param_tedlevel/10; gamestate.mapon %= 10; #endif return JE_LOOP2; } /* main game cycle */ #ifndef DEMOTEST #ifndef UPLOAD #ifndef GOODTIMES #ifndef SPEAR #ifndef JAPAN if (!param_nowait) NonShareware(); #endif #else #ifndef GOODTIMES #ifndef SPEARDEMO extern void CopyProtection(void); if(!param_goodtimes) CopyProtection(); #endif #endif #endif #endif #endif StartCPMusic(INTROSONG); #ifndef JAPAN if (!param_nowait) PG13 (); #endif #endif return JE_LOOP; case JE_LOOP: while (!param_nowait) { #ifndef DEMOTEST #ifdef SPEAR LR_Color pal[256]; /* title page */ CA_CacheGrChunk (TITLEPALETTE); VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256); CA_CacheGrChunk (TITLE1PIC); VWB_DrawPic (0,0,TITLE1PIC); UNCACHEGRCHUNK (TITLE1PIC); CA_CacheGrChunk (TITLE2PIC); VWB_DrawPic (0,80,TITLE2PIC); UNCACHEGRCHUNK (TITLE2PIC); VW_UpdateScreen (); VL_FadeIn(0,255,pal,30); UNCACHEGRCHUNK (TITLEPALETTE); #else CA_CacheScreen (TITLEPIC); VW_UpdateScreen (); VW_FadeIn(); #endif if (IN_UserInput(TickBase*15)) break; VW_FadeOut(); /* credits page */ CA_CacheScreen (CREDITSPIC); VW_UpdateScreen(); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; VW_FadeOut (); DrawHighScores (); VW_UpdateScreen (); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; #endif /* demo */ #ifndef SPEARDEMO PlayDemo (LastDemo++%4); #else PlayDemo (0); #endif if (playstate == EX_ABORT) return JE_QUIT; VW_FadeOut(); if(screenHeight % 200 != 0) VL_ClearScreen(0); StartCPMusic(INTROSONG); } VW_FadeOut (); #ifdef DEBUGKEYS if (Keyboard[sc_Tab] && param_debugmode) RecordDemo (); else #endif US_ControlPanel (0); if (startgame || loadedgame) return JE_LOOP2; break; case JE_LOOP2: id = GameLoop(); if (param_tedlevel == -1 && id == -1) { if(!param_nowait) { VW_FadeOut(); StartCPMusic(INTROSONG); } } break; } return JE_LOOP2; }
static void DemoLoop() { int LastDemo = 0; // // check for launch from ted // if (param_tedlevel != -1) { param_nowait = true; EnableEndGameMenuItem(); NewGame(param_difficulty,0); #ifndef SPEAR gamestate.episode = param_tedlevel/10; gamestate.mapon = param_tedlevel%10; #else gamestate.episode = 0; gamestate.mapon = param_tedlevel; #endif GameLoop(); Quit (NULL); } // // main game cycle // #ifndef DEMOTEST #ifndef UPLOAD #ifndef GOODTIMES #ifndef SPEAR #ifndef JAPAN if (!param_nowait) NonShareware(); #endif #else #ifndef GOODTIMES #ifndef SPEARDEMO extern void CopyProtection(void); if(!param_goodtimes) CopyProtection(); #endif #endif #endif #endif #endif StartCPMusic(INTROSONG); #ifndef JAPAN if (!param_nowait) PG13 (); #endif #endif while (1) { while (!param_nowait) { // // title page // #ifndef DEMOTEST #ifdef SPEAR SDL_Color pal[256]; CA_CacheGrChunk (TITLEPALETTE); VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256); CA_CacheGrChunk (TITLE1PIC); VWB_DrawPic (0,0,TITLE1PIC); UNCACHEGRCHUNK (TITLE1PIC); CA_CacheGrChunk (TITLE2PIC); VWB_DrawPic (0,80,TITLE2PIC); UNCACHEGRCHUNK (TITLE2PIC); VW_UpdateScreen (); VL_FadeIn(0,255,pal,30); UNCACHEGRCHUNK (TITLEPALETTE); #else CA_CacheScreen (TITLEPIC); VW_UpdateScreen (); VW_FadeIn(); #endif if (IN_UserInput(TickBase*15)) break; VW_FadeOut(); // // credits page // CA_CacheScreen (CREDITSPIC); VW_UpdateScreen(); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; VW_FadeOut (); // // high scores // DrawHighScores (); VW_UpdateScreen (); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; #endif // // demo // #ifndef SPEARDEMO PlayDemo (LastDemo++%4); #else PlayDemo (0); #endif if (playstate == ex_abort) break; VW_FadeOut(); if(screenHeight % 200 != 0) VL_ClearScreen(0); StartCPMusic(INTROSONG); } VW_FadeOut (); #ifdef DEBUGKEYS if (Keyboard[sc_Tab] && param_debugmode) RecordDemo (); else US_ControlPanel (0); #else US_ControlPanel (0); #endif if (startgame || loadedgame) { GameLoop (); if(!param_nowait) { VW_FadeOut(); StartCPMusic(INTROSONG); } } } }