From 7174a32c8e877627c51da50b657083873aeef1e6 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 5 Oct 2003 15:28:15 +0000 Subject: Made a separate class for the cutscene functions, removed some unused code and made some other minor cleanups. svn-id: r10614 --- sword2/anims.cpp | 7 +++-- sword2/build_display.cpp | 60 ++++++++++++------------------------- sword2/driver/d_draw.cpp | 78 +++++++++--------------------------------------- sword2/driver/d_draw.h | 12 ++++++++ sword2/driver/driver96.h | 1 - sword2/driver/render.cpp | 14 --------- sword2/events.cpp | 12 +++----- sword2/events.h | 3 ++ sword2/maketext.cpp | 13 ++++---- sword2/protocol.cpp | 8 ++--- sword2/router.cpp | 37 +++++++++++++---------- sword2/router.h | 5 +++- sword2/sound.cpp | 2 +- sword2/sword2.cpp | 14 +++++++++ sword2/sword2.h | 2 ++ sword2/walker.cpp | 4 +-- 16 files changed, 111 insertions(+), 161 deletions(-) (limited to 'sword2') diff --git a/sword2/anims.cpp b/sword2/anims.cpp index c164360815..eeaf5b7a76 100644 --- a/sword2/anims.cpp +++ b/sword2/anims.cpp @@ -26,6 +26,7 @@ #include "stdafx.h" #include "common/scummsys.h" #include "bs2/driver/driver96.h" +#include "bs2/driver/d_draw.h" #include "bs2/anims.h" #include "bs2/console.h" #include "bs2/controls.h" // for 'speechSelected' & 'subtitles' @@ -748,10 +749,12 @@ int32 FN_play_sequence(int32 *params) { // pause sfx during sequence, except the one used for lead-in music g_sound->pauseFxForSequence(); + MoviePlayer player; + if (sequenceTextLines && g_sword2->_gameId == GID_SWORD2) - rv = PlaySmacker(filename, sequenceSpeechArray, leadOut); + rv = player.play(filename, sequenceSpeechArray, leadOut); else - rv = PlaySmacker(filename, NULL, leadOut); + rv = player.play(filename, NULL, leadOut); // unpause sound fx again, in case we're staying in same location g_sound->unpauseFx(); diff --git a/sword2/build_display.cpp b/sword2/build_display.cpp index 217a07861a..a0c3abfabc 100644 --- a/sword2/build_display.cpp +++ b/sword2/build_display.cpp @@ -22,6 +22,7 @@ // --------------------------------------------------------------------------- #include "stdafx.h" +#include "bs2/sword2.h" #include "bs2/build_display.h" #include "bs2/console.h" #include "bs2/defs.h" @@ -106,7 +107,7 @@ void Send_fore_par1_frames(void); // // --------------------------------------------------------------------------- -void Build_display(void) { //Tony21Sept96 +void Build_display(void) { bool end; #ifdef _SWORD2_DEBUG uint8 pal[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0 }; @@ -324,8 +325,6 @@ void DisplayMsg(uint8 *text, int time) { _spriteInfo spriteInfo; _palEntry pal[256]; _palEntry oldPal[256]; - int16 oldY; - int16 oldX; uint32 rv; // drivers error return value warning("DisplayMsg: %s", (char *) text); @@ -336,16 +335,16 @@ void DisplayMsg(uint8 *text, int time) { } Set_mouse(0); - Set_luggage(0); //tw28Aug + Set_luggage(0); CloseMenuImmediately(); EraseBackBuffer(); text_spr = MakeTextSprite(text, 640, 187, speech_font_id); - frame = (_frameHeader*) text_spr->ad; + frame = (_frameHeader *) text_spr->ad; - spriteInfo.x = screenWide/2 - frame->width/2; + spriteInfo.x = screenWide / 2 - frame->width / 2; if (!time) spriteInfo.y = screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP; else @@ -359,19 +358,14 @@ void DisplayMsg(uint8 *text, int time) { spriteInfo.blend = 0; spriteInfo.data = text_spr->ad + sizeof(_frameHeader); spriteInfo.colourTable = 0; - oldX = spriteInfo.x; - oldY = spriteInfo.y; rv = DrawSprite(&spriteInfo); if (rv) error("Driver Error %.8x (in DisplayMsg)", rv); - spriteInfo.x = oldX; - spriteInfo.y = oldY; - memcpy((char *) oldPal, (char *) palCopy, 256 * sizeof(_palEntry)); - memset(pal, 0, 256*sizeof(_palEntry)); + memset(pal, 0, 256 * sizeof(_palEntry)); pal[187].red = 255; pal[187].green = 255; pal[187].blue = 255; @@ -385,19 +379,11 @@ void DisplayMsg(uint8 *text, int time) { uint32 targetTime = SVM_timeGetTime() + (time * 1000); - while (SVM_timeGetTime() < targetTime) { - ServiceWindows(); - - EraseBackBuffer(); - - rv = DrawSprite(&spriteInfo); // Keep the message there even when the user task swaps. - if (rv) - error("Driver Error %.8x (in DisplayMsg)", rv); + rv = DrawSprite(&spriteInfo); // Keep the message there even when the user task swaps. + if (rv) + error("Driver Error %.8x (in DisplayMsg)", rv); - // Drivers change the y co-ordinate, don't know why... - spriteInfo.y = oldY; - spriteInfo.x = oldX; - } + sleepUntil(targetTime); BS2_SetPalette(0, 256, (uint8 *) oldPal, RDPAL_FADE); } @@ -688,13 +674,11 @@ void Process_image(buildit *build_unit) { res_man.close(build_unit->anim_resource); } -void Reset_render_lists(void) { //Tony18Sept96 +void Reset_render_lists(void) { // reset the sort lists - do this before a logic loop // takes into account the fact that the start of the list is pre-built // with the special sortable layers - uint32 j; - cur_bgp0 = 0; cur_bgp1 = 0; cur_back = 0; @@ -707,7 +691,7 @@ void Reset_render_lists(void) { //Tony18Sept96 if (cur_sort) { // there are some layers - so rebuild the sort order // positioning - for (j = 0; j < cur_sort; j++) + for (uint j = 0; j < cur_sort; j++) sort_order[j] = j; //rebuild the order list } } @@ -719,15 +703,11 @@ void Sort_the_sort_list(void) { if (cur_sort <= 1) return; - uint16 i, j, swap; - - for (i = 0; i < cur_sort - 1; i++) { - for (j = 0; j < cur_sort - 1; j++) { + for (uint i = 0; i < cur_sort - 1; i++) { + for (uint j = 0; j < cur_sort - 1; j++) { //this > next then swap - if (sort_list[sort_order[j]].sort_y > sort_list[sort_order[j+1]].sort_y) { - swap = sort_order[j]; - sort_order[j] = sort_order[j + 1]; - sort_order[j + 1] = swap; + if (sort_list[sort_order[j]].sort_y > sort_list[sort_order[j + 1]].sort_y) { + SWAP(sort_order[j], sort_order[j + 1]); } } } @@ -854,7 +834,6 @@ void Register_frame(int32 *params, buildit *build_unit) { mouse_list[cur_mouse].priority = ob_mouse->priority; mouse_list[cur_mouse].pointer = ob_mouse->pointer; - // (James17jun97) // check if pointer text field is set due to previous // object using this slot (ie. not correct for this // one) @@ -862,6 +841,7 @@ void Register_frame(int32 *params, buildit *build_unit) { // if 'pointer_text' field is set, but the 'id' field // isn't same is current id // then we don't want this "left over" pointer text + if (mouse_list[cur_mouse].pointer_text && mouse_list[cur_mouse].id != (int32) ID) mouse_list[cur_mouse].pointer_text=0; @@ -1075,7 +1055,6 @@ void SetFullPalette(int32 palRes) { palRes = lastPaletteRes; } } else { - // (James 03sep97) // check if we're just restoring the current screen palette // because we might actually need to use a separate palette // file anyway eg. for pausing & unpausing during the eclipse @@ -1091,11 +1070,10 @@ void SetFullPalette(int32 palRes) { } //---------------------------------- - // non-zero: set palette to this separate palette file if (palRes) { // open the palette file - head = (_standardHeader*) res_man.open(palRes); + head = (_standardHeader *) res_man.open(palRes); #ifdef _SWORD2_DEBUG if (head->fileType != PALETTE_FILE) @@ -1151,7 +1129,7 @@ int32 FN_restore_game(int32 *params) { int32 FN_change_shadows(int32 *params) { uint32 rv; - // if last screen was using a shading mask (see below) (James 08apr97) + // if last screen was using a shading mask (see below) if (this_screen.mask_flag) { rv = CloseLightMask(); diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp index cba4bb1e6d..2cf7959db4 100644 --- a/sword2/driver/d_draw.cpp +++ b/sword2/driver/d_draw.cpp @@ -43,47 +43,6 @@ int16 scrolly; int32 renderCaps = 0; -int32 PlotDots(int16 x, int16 y, int16 count) { - - warning("stub PlotDots( %d, %d, %d )", x, y, count); -/* - int16 i; - uint8 *dst; - - DDSURFACEDESC ddDescription; - HRESULT hr; - - ddDescription.dwSize = sizeof(ddDescription); - - hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - if (hr != DD_OK) - { - hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - } - - if (hr == DD_OK) - { - - dst = (uint8 *) ddDescription.lpSurface + y * ddDescription.lPitch + x; - - for (i=0; i<=count; i++) - { - *dst = 184; - dst += 2; - } - dst = (uint8 *) ddDescription.lpSurface + (y+1) * ddDescription.lPitch + x; - for (i=0; i<=count/10; i++) - { - *dst = 184; - dst += 20; - } - IDirectDrawSurface2_Unlock(lpBackBuffer, ddDescription.lpSurface); - } -*/ - - return RD_OK; -} - /** * Initialise the display with the sizes passed in. * @return RD_OK, or an error code if the display cannot be set up. @@ -168,30 +127,21 @@ int32 EraseBackBuffer( void ) { return RD_OK; } - -int32 NextSmackerFrame(void) { - warning("stub NextSmackerFrame"); - return RD_OK; -} - - -static uint8 *textSurface = NULL; - -void OpenTextObject(_movieTextObject *obj) { +void MoviePlayer::openTextObject(_movieTextObject *obj) { if (obj->textSprite) - CreateSurface(obj->textSprite, &textSurface); + CreateSurface(obj->textSprite, &_textSurface); } -void CloseTextObject(_movieTextObject *obj) { - if (textSurface) { - DeleteSurface(textSurface); - textSurface = 0; +void MoviePlayer::closeTextObject(_movieTextObject *obj) { + if (_textSurface) { + DeleteSurface(_textSurface); + _textSurface = NULL; } } -void DrawTextObject(_movieTextObject *obj) { - if (obj->textSprite && textSurface) - DrawSurface(obj->textSprite, textSurface); +void MoviePlayer::drawTextObject(_movieTextObject *obj) { + if (obj->textSprite && _textSurface) + DrawSurface(obj->textSprite, _textSurface); } /** @@ -201,7 +151,7 @@ void DrawTextObject(_movieTextObject *obj) { * @param musicOut lead-out music */ -int32 PlaySmacker(char *filename, _movieTextObject *text[], uint8 *musicOut) { +int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOut) { warning("semi-stub PlaySmacker %s", filename); // WORKAROUND: For now, we just do the voice-over parts of the @@ -268,15 +218,15 @@ int32 PlaySmacker(char *filename, _movieTextObject *text[], uint8 *musicOut) { if (frameCounter == text[textCounter]->startFrame) { EraseBackBuffer(); - OpenTextObject(text[textCounter]); - DrawTextObject(text[textCounter]); + openTextObject(text[textCounter]); + drawTextObject(text[textCounter]); if (text[textCounter]->speech) { g_sword2->_mixer->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, SoundMixer::FLAG_16BITS); } } if (frameCounter == text[textCounter]->endFrame) { - CloseTextObject(text[textCounter]); + closeTextObject(text[textCounter]); EraseBackBuffer(); textCounter++; } @@ -300,7 +250,7 @@ int32 PlaySmacker(char *filename, _movieTextObject *text[], uint8 *musicOut) { g_system->delay_msecs(90); } - CloseTextObject(text[textCounter]); + closeTextObject(text[textCounter]); EraseBackBuffer(); SetNeedRedraw(); diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h index 7c24266677..a169b922e2 100644 --- a/sword2/driver/d_draw.h +++ b/sword2/driver/d_draw.h @@ -26,6 +26,18 @@ namespace Sword2 { extern byte *lpBackBuffer; +class MoviePlayer { +private: + uint8 *_textSurface; + void openTextObject(_movieTextObject *obj); + void closeTextObject(_movieTextObject *obj); + void drawTextObject(_movieTextObject *obj); + +public: + MoviePlayer() : _textSurface(NULL) {} + int32 play(char *filename, _movieTextObject *text[], uint8 *musicOut); +}; + } // End of namespace Sword2 #endif diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h index 13bbdcbbb1..f27adae736 100644 --- a/sword2/driver/driver96.h +++ b/sword2/driver/driver96.h @@ -361,7 +361,6 @@ extern int32 PlotPoint(uint16 x, uint16 y, uint8 colour); extern int32 DrawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 colour); extern int32 InitialiseBackgroundLayer(_parallax *p); extern int32 CloseBackgroundLayer(void); -extern int32 PlotDots(int16 x, int16 y, int16 count); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp index 36b36b0c47..ffae9d5518 100644 --- a/sword2/driver/render.cpp +++ b/sword2/driver/render.cpp @@ -782,20 +782,6 @@ int32 StartRenderCycle(void) { return RD_OK; } -// FIXME: Move this to some better place? - -void sleepUntil(int32 time) { - while ((int32) SVM_timeGetTime() < time) { - g_sword2->parseEvents(); - - // Make sure menu animations and fades don't suffer - ProcessMenu(); - ServiceWindows(); - - g_system->delay_msecs(10); - } -} - /** * This function should be called at the end of the render cycle. * @param end the function sets this to true if the render cycle is to be diff --git a/sword2/events.cpp b/sword2/events.cpp index d5766b9e1e..5a7ec32583 100644 --- a/sword2/events.cpp +++ b/sword2/events.cpp @@ -39,6 +39,7 @@ void Init_event_system(void) { } } +#ifdef _SWORD2_DEBUG uint32 CountEvents(void) { uint32 count = 0; @@ -49,6 +50,7 @@ uint32 CountEvents(void) { return count; } +#endif int32 FN_request_speech(int32 *params) { // change current script - must be followed by a TERMINATE script @@ -86,12 +88,6 @@ int32 FN_request_speech(int32 *params) { void Set_player_action_event(uint32 id, uint32 interact_id) { uint32 j = 0; -// if (event_list[j].id != id && event_list[j].id) -// // zip along until we find a free slot -// while (event_list[j].id!=id || event_list[j].id) { -// j++; -// } - while (1) { if (event_list[j].id == id) break; @@ -107,10 +103,10 @@ void Set_player_action_event(uint32 id, uint32 interact_id) { // found that slot - //id of person to stop + // id of person to stop event_list[j].id = id; - //full script id of action script number 2 + // full script id of action script number 2 event_list[j].interact_id = (interact_id * 65536) + 2; } diff --git a/sword2/events.h b/sword2/events.h index 43f7f826ba..600f8b3932 100644 --- a/sword2/events.h +++ b/sword2/events.h @@ -41,7 +41,10 @@ void Start_event(void); int32 FN_start_event(void); uint32 Check_event_waiting(void); void Kill_all_ids_events(uint32 id); + +#ifdef _SWORD2_DEBUG uint32 CountEvents(void); +#endif } // End of namespace Sword2 diff --git a/sword2/maketext.cpp b/sword2/maketext.cpp index 35ae08956b..5fb09bce94 100644 --- a/sword2/maketext.cpp +++ b/sword2/maketext.cpp @@ -95,7 +95,6 @@ uint8 border_pen; // output pen colour of character borders uint32 speech_font_id; uint32 controls_font_id; uint32 red_font_id; -uint32 death_font_id; mem* MakeTextSprite(uint8 *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes) { mem *line; // handle for the memory block which will @@ -450,11 +449,11 @@ typedef struct { // correct size! uint16 type; mem *text_mem; -} text_bloc; +} text_bloc; text_bloc text_sprite_list[MAX_text_blocs]; -void Init_text_bloc_system(void) { //Tony16Oct96 +void Init_text_bloc_system(void) { for (int j = 0; j < MAX_text_blocs; j++) text_sprite_list[j].text_mem = 0; } @@ -492,7 +491,7 @@ uint32 Build_new_block(uint8 *ascii, int16 x, int16 y, uint16 width, uint8 pen, // debug text just to be printed normally from point (x,y) - // JUSTIFICATION & POSITIONING (James updated 20jun97) + // JUSTIFICATION & POSITIONING // 'NO_JUSTIFICATION' means print sprite with top-left at (x,y) // without margin checking - used for debug text @@ -637,9 +636,9 @@ void InitialiseFontResourceFlags(void) { // "talenna" Finnish for "save" // "zapisz" Polish for "save" - if (strcmp((char*) textLine, "tallenna") == 0) + if (strcmp((char *) textLine, "tallenna") == 0) language = FINNISH_TEXT; - else if (strcmp((char*) textLine, "zapisz") == 0) + else if (strcmp((char *) textLine, "zapisz") == 0) language = POLISH_TEXT; else language = DEFAULT_TEXT; @@ -659,7 +658,7 @@ void InitialiseFontResourceFlags(void) { else textLine = FetchTextLine(textFile, 54) + 2; - SetWindowName((char*) textLine); + SetWindowName((char *) textLine); // now ok to close the text file res_man.close(TEXT_RES); diff --git a/sword2/protocol.cpp b/sword2/protocol.cpp index b118e376b8..2970792a17 100644 --- a/sword2/protocol.cpp +++ b/sword2/protocol.cpp @@ -172,7 +172,7 @@ uint8 *FetchTextLine(uint8 *file, uint32 text_line) { if (text_line >= text_header->noOfLines) { fileHeader = (_standardHeader*)file; - sprintf((char*) errorLine, "xxMissing line %d of %s (only 0..%d)", text_line, fileHeader->name, text_header->noOfLines - 1); + sprintf((char *) errorLine, "xxMissing line %d of %s (only 0..%d)", text_line, fileHeader->name, text_header->noOfLines - 1); // first 2 chars are NULL so that actor-number comes out as '0' @@ -182,9 +182,9 @@ uint8 *FetchTextLine(uint8 *file, uint32 text_line) { } //point to the lookup table - point = (uint32*) text_header + 1; + point = (uint32 *) text_header + 1; - return (uint8*) (file + READ_LE_UINT32(point + text_line)); + return (uint8 *) (file + READ_LE_UINT32(point + text_line)); } @@ -204,7 +204,7 @@ uint8 CheckTextLine(uint8 *file, uint32 text_line) { uint8 *FetchObjectName(int32 resourceId) { _standardHeader *header; - header = (_standardHeader*) res_man.open(resourceId); + header = (_standardHeader *) res_man.open(resourceId); res_man.close(resourceId); // note this pointer is no longer valid, but it should be ok until diff --git a/sword2/router.cpp b/sword2/router.cpp index 5515ee33fa..88411c4b2b 100644 --- a/sword2/router.cpp +++ b/sword2/router.cpp @@ -133,7 +133,10 @@ static void ExtractRoute(void); static void LoadWalkGrid(void); static void SetUpWalkGrid(Object_mega *ob_mega, int32 x, int32 y, int32 dir); static void LoadWalkData(Object_walkdata *ob_walkdata); + +#ifdef _SWORD2_DEBUG static void PlotCross(int16 x, int16 y, uint8 colour); +#endif static int32 Scan(int32 level); static int32 NewCheck(int32 status, int32 x1, int32 y1, int32 x2, int32 y2); @@ -483,7 +486,7 @@ int32 GetRoute(void) { do { changed = Scan(level); level++; - } while(changed == 1); + } while (changed == 1); // Check to see if the route reached the target @@ -680,7 +683,7 @@ int32 SmoothestPath() { // route.X route.Y route.dir and bestTurns start at far end p++; - } while (p < (routeLength)); + } while (p < routeLength); // best turns will end heading as near as possible to target dir rest // is down to anim for now @@ -987,7 +990,7 @@ void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) { walkAnim[walk_pc].step = 0; debug(5, "SLOW-OUT FRAME: walkAnim[%d].frame = %d",walk_pc, walkAnim[walk_pc].frame); walk_pc++; - } while(walkAnim[walk_pc].step > 0); + } while (walkAnim[walk_pc].step > 0); // add stationary frame(s) (OPTIONAL) @@ -1050,7 +1053,7 @@ void AddSlowOutFrames(_walkData *walkAnim) { debug(5, "walkAnim[%d].frame = %d",slowOutFrameNo,walkAnim[slowOutFrameNo].frame); slowOutFrameNo++; - } while(slowOutFrameNo < lastCount); + } while (slowOutFrameNo < lastCount); // add stationary frame(s) (OPTIONAL) @@ -1264,7 +1267,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { stepCount++; step++; module++; - } while(module < moduleEnd); + } while (module < moduleEnd); stepX = modX[modularPath[p].dir]; stepY = modY[modularPath[p].dir]; @@ -1323,7 +1326,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { do { frameCount++; walkAnim[lastCount + frameCount - 1].x += errorX * frameCount / frames; - } while(frameCount < frames); + } while (frameCount < frames); } if (errorY != 0) { @@ -1332,7 +1335,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { do { frameCount++; walkAnim[lastCount + frameCount - 1].y += errorY * frameCount / frames; - } while(frameCount < frames); + } while (frameCount < frames); } // Now is the time to put in the turn frames @@ -1375,7 +1378,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { // turning right walkAnim[frame].frame += firstWalkingTurnRightFrame; frame++; - } while(frame < lastCount); + } while (frame < lastCount); } lastDir = currentDir; } @@ -1735,7 +1738,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { currentDir = 99; do { - while(modularPath[p].num > 0) { + while (modularPath[p].num > 0) { currentDir = modularPath[p].dir; if (currentDir< NO_DIRECTIONS) { module = currentDir * framesPerStep * 2 + left; @@ -1762,7 +1765,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { stepCount++; module++; step++; - } while( module < moduleEnd); + } while (module < moduleEnd); errorX = modularPath[p].x - moduleX; errorX = errorX * modX[modularPath[p].dir]; @@ -1797,8 +1800,8 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { // walk if (slowStart == 1) { - stepCount -= numberOfSlowInFrames[currentDir]; // (James08sep97) - lastCount -= numberOfSlowInFrames[currentDir]; // (James08sep97) + stepCount -= numberOfSlowInFrames[currentDir]; + lastCount -= numberOfSlowInFrames[currentDir]; slowStart = 0; } @@ -2254,7 +2257,7 @@ int32 LineCheck(int32 x1, int32 y1, int32 x2, int32 y2) { } } i++; - } while(i < nbars && linesCrossed); + } while (i < nbars && linesCrossed); return linesCrossed; } @@ -2301,7 +2304,7 @@ int32 HorizCheck(int32 x1, int32 y, int32 x2) { } } i++; - } while(i < nbars && linesCrossed); + } while (i < nbars && linesCrossed); return linesCrossed; } @@ -2351,7 +2354,7 @@ int32 VertCheck(int32 x, int32 y1, int32 y2) { } } i++; - } while(i < nbars && linesCrossed); + } while (i < nbars && linesCrossed); return linesCrossed; } @@ -2418,7 +2421,7 @@ int32 CheckTarget(int32 x, int32 y) { } } i++; - } while(i < nbars && onLine == 0); + } while (i < nbars && onLine == 0); return onLine; } @@ -2694,6 +2697,7 @@ void SetUpWalkGrid(Object_mega *ob_mega, int32 x, int32 y, int32 dir) { node[nnodes].dist = 9999; } +#ifdef _SWORD2_DEBUG void PlotWalkGrid(void) { int32 j; @@ -2716,6 +2720,7 @@ void PlotCross(int16 x, int16 y, uint8 colour) { DrawLine(x - 1, y - 1, x + 1, y + 1, colour); DrawLine(x + 1, y - 1, x - 1, y + 1, colour); } +#endif void LoadWalkGrid(void) { _walkGridHeader floorHeader; diff --git a/sword2/router.h b/sword2/router.h index be9bea8e2f..9611f4cf5f 100644 --- a/sword2/router.h +++ b/sword2/router.h @@ -72,11 +72,14 @@ _walkData* LockRouteMem(void); void FloatRouteMem(void); void FreeRouteMem(void); void FreeAllRouteMem(void); -void PlotWalkGrid(void); void AddWalkGrid(int32 gridResource); void RemoveWalkGrid(int32 gridResource); void ClearWalkGridList(void); +#ifdef _SWORD2_DEBUG +void PlotWalkGrid(void); +#endif + } // End of namespace Sword2 #endif diff --git a/sword2/sound.cpp b/sword2/sound.cpp index 2a9ddd8496..cd9c5157be 100644 --- a/sword2/sound.cpp +++ b/sword2/sound.cpp @@ -398,7 +398,7 @@ int32 FN_stop_music(int32 *params) { // called from script only return IR_CONT; } -void Kill_music(void) { // James22aug97 +void Kill_music(void) { looping_music_id = 0; // clear the 'looping' flag g_sound->stopMusic(); } diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index cf11daa697..214ffbbcf1 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -462,6 +462,20 @@ void Sword2Engine::Start_game(void) { debug(5, "Start_game() DONE."); } +// FIXME: Move this to some better place? + +void sleepUntil(int32 time) { + while ((int32) SVM_timeGetTime() < time) { + g_sword2->parseEvents(); + + // Make sure menu animations and fades don't suffer + ProcessMenu(); + ServiceWindows(); + + g_system->delay_msecs(10); + } +} + void PauseGame(void) { // uint8 *text; diff --git a/sword2/sword2.h b/sword2/sword2.h index 20e5310578..8d592879ae 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -50,6 +50,8 @@ void Close_game(); void PauseGame(void); void UnpauseGame(void); +void sleepUntil(int32 time); + #define HEAD_LEN 8 extern uint8 version_string[]; // for displaying from the console diff --git a/sword2/walker.cpp b/sword2/walker.cpp index afc5c932a4..311cee2b54 100644 --- a/sword2/walker.cpp +++ b/sword2/walker.cpp @@ -162,7 +162,7 @@ int32 FN_walk(int32 *params) { // it in script to check if a 2nd-click came along // EXIT_FADING = 0; - // finished walk (James23jun97) + // finished walk ob_mega->currently_walking = 0; // (see FN_get_player_savedata() in save_rest.cpp @@ -207,7 +207,7 @@ int32 FN_walk(int32 *params) { ob_logic->looping = 0; // so script loop stops FreeRouteMem(); // free up the walkdata mem block - // finished walk(James23jun97) + // finished walk ob_mega->currently_walking = 0; // (see FN_get_player_savedata() in save_rest.cpp -- cgit v1.2.3