From: Holger Schemel Date: Tue, 31 May 2016 10:12:40 +0000 (+0200) Subject: cleanup of tape recorder state handling X-Git-Tag: 4.0.0.0-rc3~42 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=50a408da2e60177326e842a9e7c8e5bf80a9b0e1;p=rocksndiamonds.git cleanup of tape recorder state handling --- diff --git a/src/game.c b/src/game.c index 8739b9f8..81ac077a 100644 --- a/src/game.c +++ b/src/game.c @@ -15094,8 +15094,7 @@ void GameUndoRedoExt() DrawCompleteVideoDisplay(); DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime); DrawVideoDisplay(VIDEO_STATE_FRAME_ON, FrameCounter); - DrawVideoDisplay((tape.single_step ? VIDEO_STATE_1STEP_ON : - VIDEO_STATE_1STEP_OFF), 0); + DrawVideoDisplay(VIDEO_STATE_1STEP(tape.single_step), 0); BackToFront(); } diff --git a/src/tape.c b/src/tape.c index d2a0b749..0c389a6b 100644 --- a/src/tape.c +++ b/src/tape.c @@ -734,17 +734,17 @@ void TapeTogglePause(boolean toggle_manual) if (tape.single_step && toggle_manual) tape.single_step = FALSE; - state |= (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF); + state |= VIDEO_STATE_PAUSE(tape.pausing); if (tape.pause_before_death) - state |= (tape.pausing ? VIDEO_STATE_PBEND_OFF : VIDEO_STATE_PBEND_ON); + state |= VIDEO_STATE_PBEND(!tape.pausing); else if (tape.fast_forward) - state |= (tape.pausing ? VIDEO_STATE_FFWD_OFF : VIDEO_STATE_FFWD_ON); + state |= VIDEO_STATE_FFWD(!tape.pausing); if (tape.playing) state |= VIDEO_STATE_PLAY_ON; else - state |= (tape.single_step ? VIDEO_STATE_1STEP_ON : VIDEO_STATE_1STEP_OFF); + state |= VIDEO_STATE_1STEP(tape.single_step); DrawVideoDisplay(state, 0); @@ -860,13 +860,9 @@ byte *TapePlayAction() if (update_video_display && !tape.deactivate_display) { if (tape.pause_before_death) - DrawVideoDisplayLabel(update_draw_label_on ? - VIDEO_STATE_PBEND_ON : - VIDEO_STATE_PBEND_OFF); + DrawVideoDisplayLabel(VIDEO_STATE_PBEND(update_draw_label_on)); else if (tape.fast_forward) - DrawVideoDisplayLabel(update_draw_label_on ? - VIDEO_STATE_FFWD_ON : - VIDEO_STATE_FFWD_OFF); + DrawVideoDisplayLabel(VIDEO_STATE_FFWD(update_draw_label_on)); if (tape.warp_forward) DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON); @@ -974,7 +970,7 @@ static void TapeStartWarpForward() static void TapeStopWarpForward() { - int state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF); + int state = VIDEO_STATE_PAUSE(tape.pausing); if (tape.deactivate_display) tape.pause_before_death = FALSE; @@ -984,12 +980,10 @@ static void TapeStopWarpForward() TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING); - if (tape.pause_before_death) - state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_PBEND_ON; - else if (tape.fast_forward) - state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_FFWD_ON; - else - state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_PLAY_ON; + state |= VIDEO_STATE_WARP_OFF; + state |= (tape.pause_before_death ? VIDEO_STATE_PBEND_ON : + tape.fast_forward ? VIDEO_STATE_FFWD_ON : + VIDEO_STATE_PLAY_ON); DrawVideoDisplay(state, 0); } @@ -1004,8 +998,7 @@ static void TapeSingleStep() tape.single_step = !tape.single_step; - DrawVideoDisplay((tape.single_step ? VIDEO_STATE_1STEP_ON : - VIDEO_STATE_1STEP_OFF), 0); + DrawVideoDisplay(VIDEO_STATE_1STEP(tape.single_step), 0); } void TapeQuickSave() diff --git a/src/tape.h b/src/tape.h index 34f17889..4eea1de0 100644 --- a/src/tape.h +++ b/src/tape.h @@ -37,54 +37,53 @@ /* values for video tape control */ #define VIDEO_STATE_PLAY_OFF (1 << 0) #define VIDEO_STATE_PLAY_ON (1 << 1) -#define VIDEO_STATE_PLAY (VIDEO_STATE_PLAY_OFF | VIDEO_STATE_PLAY_ON) #define VIDEO_STATE_REC_OFF (1 << 2) #define VIDEO_STATE_REC_ON (1 << 3) -#define VIDEO_STATE_REC (VIDEO_STATE_REC_OFF | VIDEO_STATE_REC_ON) #define VIDEO_STATE_PAUSE_OFF (1 << 4) #define VIDEO_STATE_PAUSE_ON (1 << 5) -#define VIDEO_STATE_PAUSE (VIDEO_STATE_PAUSE_OFF | VIDEO_STATE_PAUSE_ON) #define VIDEO_STATE_DATE_OFF (1 << 6) #define VIDEO_STATE_DATE_ON (1 << 7) -#define VIDEO_STATE_DATE (VIDEO_STATE_DATE_OFF | VIDEO_STATE_DATE_ON) #define VIDEO_STATE_TIME_OFF (1 << 8) #define VIDEO_STATE_TIME_ON (1 << 9) -#define VIDEO_STATE_TIME (VIDEO_STATE_TIME_OFF | VIDEO_STATE_TIME_ON) #define VIDEO_STATE_FRAME_OFF (1 << 10) #define VIDEO_STATE_FRAME_ON (1 << 11) -#define VIDEO_STATE_FRAME (VIDEO_STATE_FRAME_OFF | VIDEO_STATE_FRAME_ON) - #define VIDEO_STATE_FFWD_OFF (1 << 12) #define VIDEO_STATE_FFWD_ON (1 << 13) -#define VIDEO_STATE_FFWD (VIDEO_STATE_FFWD_OFF | VIDEO_STATE_FFWD_ON) #define VIDEO_STATE_PBEND_OFF (1 << 14) #define VIDEO_STATE_PBEND_ON (1 << 15) -#define VIDEO_STATE_PBEND (VIDEO_STATE_PBEND_OFF | VIDEO_STATE_PBEND_ON) #define VIDEO_STATE_WARP_OFF (1 << 16) #define VIDEO_STATE_WARP_ON (1 << 17) -#define VIDEO_STATE_WARP (VIDEO_STATE_WARP_OFF | VIDEO_STATE_WARP_ON) #define VIDEO_STATE_WARP2_OFF (1 << 18) #define VIDEO_STATE_WARP2_ON (1 << 19) -#define VIDEO_STATE_WARP2 (VIDEO_STATE_WARP2_OFF | VIDEO_STATE_WARP2_ON) #define VIDEO_STATE_1STEP_OFF (1 << 20) #define VIDEO_STATE_1STEP_ON (1 << 21) -#define VIDEO_STATE_1STEP (VIDEO_STATE_1STEP_OFF | VIDEO_STATE_1STEP_ON) - #define VIDEO_PRESS_PLAY_ON (1 << 22) #define VIDEO_PRESS_PLAY_OFF (1 << 23) -#define VIDEO_PRESS_PLAY (VIDEO_PRESS_PLAY_OFF | VIDEO_PRESS_PLAY_ON) #define VIDEO_PRESS_REC_ON (1 << 24) #define VIDEO_PRESS_REC_OFF (1 << 25) -#define VIDEO_PRESS_REC (VIDEO_PRESS_REC_OFF | VIDEO_PRESS_REC_ON) #define VIDEO_PRESS_PAUSE_ON (1 << 26) #define VIDEO_PRESS_PAUSE_OFF (1 << 27) -#define VIDEO_PRESS_PAUSE (VIDEO_PRESS_PAUSE_OFF | VIDEO_PRESS_PAUSE_ON) #define VIDEO_PRESS_STOP_ON (1 << 28) #define VIDEO_PRESS_STOP_OFF (1 << 29) -#define VIDEO_PRESS_STOP (VIDEO_PRESS_STOP_OFF | VIDEO_PRESS_STOP_ON) #define VIDEO_PRESS_EJECT_ON (1 << 30) #define VIDEO_PRESS_EJECT_OFF (1 << 31) -#define VIDEO_PRESS_EJECT (VIDEO_PRESS_EJECT_OFF | VIDEO_PRESS_EJECT_ON) + +#define VIDEO_STATE_PLAY(x) ((x) ? VIDEO_STATE_PLAY_ON : VIDEO_STATE_PLAY_OFF) +#define VIDEO_STATE_REC(x) ((x) ? VIDEO_STATE_REC_ON : VIDEO_STATE_REC_OFF) +#define VIDEO_STATE_PAUSE(x) ((x) ? VIDEO_STATE_PAUSE_ON: VIDEO_STATE_PAUSE_OFF) +#define VIDEO_STATE_DATE(x) ((x) ? VIDEO_STATE_DATE_ON : VIDEO_STATE_DATE_OFF) +#define VIDEO_STATE_TIME(x) ((x) ? VIDEO_STATE_TIME_ON : VIDEO_STATE_TIME_OFF) +#define VIDEO_STATE_FRAME(x) ((x) ? VIDEO_STATE_FRAME_ON: VIDEO_STATE_FRAME_OFF) +#define VIDEO_STATE_FFWD(x) ((x) ? VIDEO_STATE_FFWD_ON : VIDEO_STATE_FFWD_OFF) +#define VIDEO_STATE_PBEND(x) ((x) ? VIDEO_STATE_PBEND_ON: VIDEO_STATE_PBEND_OFF) +#define VIDEO_STATE_WARP(x) ((x) ? VIDEO_STATE_WARP_ON : VIDEO_STATE_WARP_OFF) +#define VIDEO_STATE_WARP2(x) ((x) ? VIDEO_STATE_WARP2_ON: VIDEO_STATE_WARP2_OFF) +#define VIDEO_STATE_1STEP(x) ((x) ? VIDEO_STATE_1STEP_ON: VIDEO_STATE_1STEP_OFF) +#define VIDEO_PRESS_PLAY(x) ((x) ? VIDEO_PRESS_PLAY_ON : VIDEO_PRESS_PLAY_OFF) +#define VIDEO_PRESS_REC(x) ((x) ? VIDEO_PRESS_REC_ON : VIDEO_PRESS_REC_OFF) +#define VIDEO_PRESS_PAUSE(x) ((x) ? VIDEO_PRESS_PAUSE_ON: VIDEO_PRESS_PAUSE_OFF) +#define VIDEO_PRESS_STOP(x) ((x) ? VIDEO_PRESS_STOP_ON : VIDEO_PRESS_STOP_OFF) +#define VIDEO_PRESS_EJECT(x) ((x) ? VIDEO_PRESS_EJECT_ON: VIDEO_PRESS_EJECT_OFF) /* tags to draw video display labels or symbols only */ /* (negative values to prevent misinterpretation in DrawVideoDisplay(), where