// Game initialization void dodGame::COMINI() { Uint32 ticks1, ticks2; scheduler.SYSTCB(); object.CreateAll(); player.HBEATF = 0; viewer.clearArea(&viewer.TXTSTS); viewer.clearArea(&viewer.TXTPRI); viewer.VXSCAL = 0x80; viewer.VYSCAL = 0x80; viewer.VXSCALf = 128.0f; viewer.VYSCALf = 128.0f; AUTFLG = viewer.ShowFade(Viewer::FADE_BEGIN); //AUTFLG = scheduler.fadeLoop(); //AUTFLG = false; // TAKE THIS LINE OUT !!!!!!!!!! [Prevents demo from starting] player.setInitialObjects(AUTFLG); viewer.displayPrepare(); viewer.display_mode = Viewer::MODE_TITLE; viewer.draw_game(); // Delay with "PREPARE!" on screen ticks1 = SDL_GetTicks(); do { oslink.process_events(); ticks2 = SDL_GetTicks(); } while (ticks2 < ticks1 + viewer.prepPause); creature.NEWLVL(); if (AUTFLG) { // do map viewer.display_mode = Viewer::MODE_TITLE; viewer.showSeerMap = true; --viewer.UPDATE; viewer.draw_game(); // wait 3 seconds ticks1 = SDL_GetTicks(); do { oslink.process_events(); ticks2 = SDL_GetTicks(); } while (ticks2 < ticks1 + 3000); } INIVU(); viewer.PROMPT(); }
void dodGame::Restart() { Uint32 ticks1, ticks2; object.Reset(); creature.Reset(); parser.Reset(); player.Reset(); scheduler.Reset(); viewer.Reset(); hasWon = false; dungeon.VFTPTR = 0; scheduler.SYSTCB(); object.CreateAll(); player.HBEATF = 0; player.setInitialObjects(false); viewer.displayPrepare(); viewer.displayCopyright(); viewer.display_mode = Viewer::MODE_TITLE; viewer.draw_game(); // Delay with "PREPARE!" on screen ticks1 = SDL_GetTicks(); do { oslink.process_events(); ticks2 = SDL_GetTicks(); } while (ticks2 < ticks1 + 2500); creature.NEWLVL(); INIVU(); viewer.PROMPT(); }
void dodGame::LoadGame() { scheduler.LOAD(); viewer.setVidInv((game.LEVEL % 2) ?true: false); --viewer.UPDATE; viewer.draw_game(); INIVU(); viewer.PROMPT(); }
// This is the heart of the game, literally. It manages // the heartbeat, calls for the screen to be redrawn, and // polls the OS for key strokes. // // This routine is called every 17 milliseconds from the // scheduler, and also from the blocking loops after each // sound, which allows the heartbeat to mix in with the // other sounds. void Scheduler::CLOCK() { // Update Task's next_time TCBLND[0].next_time = curTime + TCBLND[0].frequency; // Update elaplsed time elapsedTime = curTime - TCBLND[0].prev_time; // Reality check if (elapsedTime > 126 * 17) { elapsedTime = 126 * 17; } if (elapsedTime >= 17) { // Update Task's prev_time TCBLND[0].prev_time = curTime; if (player.HBEATF != 0) { player.HEARTC -= (elapsedTime / 17); if ((player.HEARTC & 0x80) != 0) { player.HEARTC = 0; } if (player.HEARTC == 0) { player.HEARTC = player.HEARTR; // make sound Mix_PlayChannel(hrtChannel, hrtSound[(dodBYTE) (player.HEARTS + 1)], 0); while (Mix_Playing(hrtChannel) == 1) ; // !!! if (player.HEARTF != 0) { if ((player.HEARTS & 0x80) != 0) { // small viewer.statArea[15] = '<'; viewer.statArea[16] = '>'; player.HEARTS = 0; } else { // large viewer.statArea[15] = '{'; viewer.statArea[16] = '}'; player.HEARTS = -1; } if (!player.turning) { --viewer.UPDATE; viewer.draw_game(); } } } } } if (player.FAINT == 0) { if (game.AUTFLG) { // Abort demo on keypress if (keyCheck()) { game.hasWon = true; game.demoRestart = false; } } else { // Perform Keyboard Input oslink.process_events(); } } }
// This method gets called from the scheduler as often // as possible. It retrieves keyboard input, or commands // from the demo data. int Player::PLAYER() { int tokCnt, tokCtr; dodBYTE objstr[10]; dodBYTE * X, * U; int Xup; // Update Task's next_time scheduler.TCBLND[Scheduler::TID_PLAYER].next_time = scheduler.curTime + scheduler.TCBLND[Scheduler::TID_PLAYER].frequency; dodBYTE c; if (game.AUTFLG == 0) { // Process Keyboard Buffer do { c = parser.KBDGET(); if (c == 0) { return 0; } if (FAINT != 0) { while (parser.KBDGET() != 0) ; // loop !!! return 0; } // Convert from ASCII to Internal Codes if (c >= 'A' && c <= 'Z') { c &= 0x1F; } else if (c == parser.C_BS) { c = parser.I_BS; } else if (c == parser.C_CR) { c = parser.I_CR; } else { c = parser.I_SP; } if(!HUMAN(c)) return -1; } while (true); } else { // Process Autoplay Commands tokCnt = game.DEMO_CMDS[game.DEMOPTR++]; if (tokCnt == 0) { game.WAIT(); game.WAIT(); game.hasWon = true; game.demoRestart = true; return 0; } // Feed next autoplay command to HUMAN tokCtr = 1; do { if (tokCtr == 1) { X = &parser.CMDTAB[game.DEMO_CMDS[game.DEMOPTR]]; } else if (tokCtr == 2) { X = &parser.DIRTAB[game.DEMO_CMDS[game.DEMOPTR]]; } else { X = &object.GENTAB[game.DEMO_CMDS[game.DEMOPTR]]; } ++game.DEMOPTR; U = &objstr[1]; parser.EXPAND(X, &Xup, U); ++U; game.WAIT(); do { HUMAN(*U); ++U; } while (*U != 0xFF); HUMAN(parser.I_SP); ++tokCtr; } while (tokCtr <= tokCnt); --viewer.UPDATE; viewer.draw_game(); HUMAN(parser.I_CR); } return 0; }