X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftape.c;h=bc258b66fae809f9b53889abf9958a0048b38454;hb=d1eb03c63b0eaa2fd1bfa97d4b68ef678aa07bd2;hp=116f11cf51da41b9ce5c3e3ad44f273712b835d5;hpb=7d07216e7f18ff03a650f53e0bfb372b07782ca2;p=rocksndiamonds.git diff --git a/src/tape.c b/src/tape.c index 116f11cf..bc258b66 100644 --- a/src/tape.c +++ b/src/tape.c @@ -194,6 +194,8 @@ void DrawVideoDisplay(unsigned long state, unsigned long value) "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; + +#if 0 static struct { int gd_x1, gd_y1; @@ -344,6 +346,131 @@ void DrawVideoDisplay(unsigned long state, unsigned long value) } }, }; +#endif + +#if 1 + static struct + { + int graphic; + struct Rect *pos; + } + video_pos[NUM_TAPE_FUNCTIONS][NUM_TAPE_FUNCTION_PARTS] = + { + { + { IMG_TAPE_LABEL_GFX_PLAY, &tape.label.play }, + { IMG_TAPE_SYMBOL_GFX_PLAY, &tape.symbol.play }, + }, + { + { IMG_TAPE_LABEL_GFX_RECORD, &tape.label.record }, + { IMG_TAPE_SYMBOL_GFX_RECORD, &tape.symbol.record }, + }, + { + { IMG_TAPE_LABEL_GFX_PAUSE, &tape.label.pause }, + { IMG_TAPE_SYMBOL_GFX_PAUSE, &tape.symbol.pause }, + }, + { + { IMG_TAPE_LABEL_GFX_DATE, &tape.label.date }, + { -1, NULL }, + }, + { + { IMG_TAPE_LABEL_GFX_TIME, &tape.label.time }, + { -1, NULL }, + }, + { + { IMG_TAPE_LABEL_GFX_FAST_FORWARD, &tape.label.fast_forward }, + { IMG_TAPE_SYMBOL_GFX_FAST_FORWARD, &tape.symbol.fast_forward }, + }, + { + { IMG_TAPE_LABEL_GFX_PAUSE_BEFORE_END, &tape.label.pause_before_end }, + { IMG_TAPE_SYMBOL_GFX_PAUSE_BEFORE_END, &tape.symbol.pause_before_end }, + }, + { + { IMG_TAPE_LABEL_GFX_WARP_FORWARD_BLIND, &tape.label.warp_forward_blind}, + { IMG_TAPE_SYMBOL_GFX_WARP_FORWARD_BLIND, &tape.symbol.warp_forward_blind}, + }, + { + { IMG_TAPE_LABEL_GFX_WARP_FORWARD, &tape.label.warp_forward }, + { IMG_TAPE_SYMBOL_GFX_WARP_FORWARD, &tape.symbol.warp_forward }, + }, + { + { IMG_TAPE_LABEL_GFX_SINGLE_STEP, &tape.label.single_step }, + { IMG_TAPE_SYMBOL_GFX_SINGLE_STEP, &tape.symbol.single_step }, + }, + }; + + for (k = 0; k < NUM_TAPE_FUNCTION_STATES; k++) /* on or off states */ + { + for (i = 0; i < NUM_TAPE_FUNCTIONS; i++) /* record, play, ... */ + { + for (j = 0; j < NUM_TAPE_FUNCTION_PARTS; j++) /* label or symbol */ + { + if (video_pos[i][j].graphic == -1 || + video_pos[i][j].pos->x < 0 || + video_pos[i][j].pos->y < 0) + continue; + +#if 0 + printf("::: %d: %d, %ld\n", + i, + video_pos[i][j].graphic, + graphic_info[video_pos[i][j].graphic].bitmap); +#endif + +#if 0 + if (i < 9) + continue; +#endif + + if (state & (1 << (i * 2 + k))) + { + struct GraphicInfo *gfx_bg = &graphic_info[IMG_BACKGROUND_TAPE]; + struct GraphicInfo *gfx = &graphic_info[video_pos[i][j].graphic]; + struct Rect *pos = video_pos[i][j].pos; + Bitmap *gd_bitmap; + int gd_x, gd_y; + int skip_value = + (j == 0 ? VIDEO_DISPLAY_SYMBOL_ONLY : VIDEO_DISPLAY_LABEL_ONLY); + + if (value == skip_value) + continue; + + if (k == 1) /* on */ + { + gd_bitmap = gfx->bitmap; + gd_x = gfx->src_x; + gd_y = gfx->src_y; + } + else /* off */ + { + gd_bitmap = gfx_bg->bitmap; + gd_x = gfx_bg->src_x + pos->x; + gd_y = gfx_bg->src_y + pos->y; + } + +#if 0 + printf("::: %d (%d): %d, %ld - %d [%d] [%d] [%d]\n", + i, k, + video_pos[i][j].graphic, + graphic_info[video_pos[i][j].graphic].bitmap, + gfx->bitmap, + gd_bitmap, + (gd_bitmap == NULL), + 0); + + if (gd_bitmap == NULL) + printf("::: gfx %d skipped\n", video_pos[i][j].graphic); +#endif + + /* some tape graphics may be undefined -- only draw if defined */ + if (gd_bitmap != NULL) + BlitBitmap(gd_bitmap, drawto, gd_x, gd_y, gfx->width, gfx->height, + VX + pos->x, VY + pos->y); + } + } + } + } + +#else for (k = 0; k < NUM_TAPE_FUNCTION_STATES; k++) /* on or off states */ { @@ -379,6 +506,32 @@ void DrawVideoDisplay(unsigned long state, unsigned long value) } } } +#endif + +#if 1 + if (state & VIDEO_STATE_DATE_ON) + { + struct TextPosInfo *pos = &tape.text.date; + int tag = value % 100; + int monat = (value/100) % 100; + int jahr = (value/10000); + + DrawText(VX + pos->x, VY + pos->y, int2str(tag, 2), pos->font); + DrawText(VX + pos->x + 27, VY + pos->y, monatsname[monat], pos->font); + DrawText(VX + pos->x + 64, VY + pos->y, int2str(jahr, 2), pos->font); + } + + if (state & VIDEO_STATE_TIME_ON) + { + struct TextPosInfo *pos = &tape.text.time; + int min = value / 60; + int sec = value % 60; + + DrawText(VX + pos->x, VY + pos->y, int2str(min, 2), pos->font); + DrawText(VX + pos->x + 27, VY + pos->y, int2str(sec, 2), pos->font); + } + +#else if (state & VIDEO_STATE_DATE_ON) { @@ -404,6 +557,7 @@ void DrawVideoDisplay(unsigned long state, unsigned long value) DrawText(VX + VIDEO_TIME_XPOS + 27, VY + VIDEO_TIME_YPOS, int2str(sec, 2), FONT_TAPE_RECORDER); } +#endif redraw_mask |= REDRAW_DOOR_2; } @@ -1197,90 +1351,38 @@ void AutoPlayTape() /* ---------- new tape button stuff ---------------------------------------- */ -/* graphic position values for tape buttons */ -#define TAPE_BUTTON_XSIZE 18 -#define TAPE_BUTTON_YSIZE 18 -#define TAPE_BUTTON_XPOS 5 -#define TAPE_BUTTON_YPOS 77 - -#define TAPE_BUTTON_EJECT_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE) -#define TAPE_BUTTON_EXTRA_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE) -#define TAPE_BUTTON_STOP_XPOS (TAPE_BUTTON_XPOS + 1 * TAPE_BUTTON_XSIZE) -#define TAPE_BUTTON_PAUSE_XPOS (TAPE_BUTTON_XPOS + 2 * TAPE_BUTTON_XSIZE) -#define TAPE_BUTTON_RECORD_XPOS (TAPE_BUTTON_XPOS + 3 * TAPE_BUTTON_XSIZE) -#define TAPE_BUTTON_PLAY_XPOS (TAPE_BUTTON_XPOS + 4 * TAPE_BUTTON_XSIZE) - static struct { -#if 1 - struct Rect *tbi; int graphic; -#else - int x, y; -#endif + struct Rect *pos; int gadget_id; char *infotext; } tapebutton_info[NUM_TAPE_BUTTONS] = { { -#if 1 - &tape.button.eject, - IMG_TAPE_BUTTON_GFX_EJECT, -#else - TAPE_BUTTON_EJECT_XPOS, TAPE_BUTTON_YPOS, -#endif - TAPE_CTRL_ID_EJECT, - "eject tape" + IMG_TAPE_BUTTON_GFX_EJECT, &tape.button.eject, + TAPE_CTRL_ID_EJECT, "eject tape" }, { -#if 1 - &tape.button.eject, /* (same position as "eject" button) */ - IMG_TAPE_BUTTON_GFX_EXTRA, -#else - TAPE_BUTTON_EXTRA_XPOS, TAPE_BUTTON_YPOS, -#endif - TAPE_CTRL_ID_EXTRA, - "extra functions" + /* (same position as "eject" button) */ + IMG_TAPE_BUTTON_GFX_EXTRA, &tape.button.eject, + TAPE_CTRL_ID_EXTRA, "extra functions" }, { -#if 1 - &tape.button.stop, - IMG_TAPE_BUTTON_GFX_STOP, -#else - TAPE_BUTTON_STOP_XPOS, TAPE_BUTTON_YPOS, -#endif - TAPE_CTRL_ID_STOP, - "stop tape" + IMG_TAPE_BUTTON_GFX_STOP, &tape.button.stop, + TAPE_CTRL_ID_STOP, "stop tape" }, { -#if 1 - &tape.button.pause, - IMG_TAPE_BUTTON_GFX_PAUSE, -#else - TAPE_BUTTON_PAUSE_XPOS, TAPE_BUTTON_YPOS, -#endif - TAPE_CTRL_ID_PAUSE, - "pause tape" + IMG_TAPE_BUTTON_GFX_PAUSE, &tape.button.pause, + TAPE_CTRL_ID_PAUSE, "pause tape" }, { -#if 1 - &tape.button.record, - IMG_TAPE_BUTTON_GFX_RECORD, -#else - TAPE_BUTTON_RECORD_XPOS, TAPE_BUTTON_YPOS, -#endif - TAPE_CTRL_ID_RECORD, - "record tape" + IMG_TAPE_BUTTON_GFX_RECORD, &tape.button.record, + TAPE_CTRL_ID_RECORD, "record tape" }, { -#if 1 - &tape.button.play, - IMG_TAPE_BUTTON_GFX_PLAY, -#else - TAPE_BUTTON_PLAY_XPOS, TAPE_BUTTON_YPOS, -#endif - TAPE_CTRL_ID_PLAY, - "play tape" + IMG_TAPE_BUTTON_GFX_PLAY, &tape.button.play, + TAPE_CTRL_ID_PLAY, "play tape" } }; @@ -1290,58 +1392,25 @@ void CreateTapeButtons() for (i = 0; i < NUM_TAPE_BUTTONS; i++) { -#if 1 - // struct TapeButtonInfo *tbi = tapebutton_info[i].tbi; - int graphic = tapebutton_info[i].graphic; - Bitmap *gd_bitmap = graphic_info[graphic].bitmap; -#else - Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; -#endif + struct GraphicInfo *gfx = &graphic_info[tapebutton_info[i].graphic]; + struct Rect *pos = tapebutton_info[i].pos; struct GadgetInfo *gi; - int gd_xoffset, gd_yoffset; -#if 1 - int gd_x1, gd_x2, gd_y1, gd_y2; -#else - int gd_x1, gd_x2, gd_y; -#endif + int gd_x = gfx->src_x; + int gd_y = gfx->src_y; + int gd_xp = gfx->src_x + gfx->pressed_xoffset; + int gd_yp = gfx->src_y + gfx->pressed_yoffset; int id = i; -#if 1 - gd_x1 = graphic_info[graphic].src_x; - gd_y1 = graphic_info[graphic].src_y; - gd_x2 = gd_x1 + graphic_info[graphic].pressed_xoffset; - gd_y2 = gd_y1 + graphic_info[graphic].pressed_yoffset; - gd_xoffset = tapebutton_info[i].tbi->x; - gd_yoffset = tapebutton_info[i].tbi->y; -#else - gd_xoffset = tapebutton_info[i].x; - gd_yoffset = tapebutton_info[i].y; - gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset; - gd_y = DOOR_GFX_PAGEY2 + gd_yoffset; - - if (i == TAPE_CTRL_ID_EXTRA) - { - gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset; - } -#endif - gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_INFO_TEXT, tapebutton_info[i].infotext, - GDI_X, VX + gd_xoffset, - GDI_Y, VY + gd_yoffset, - GDI_WIDTH, TAPE_BUTTON_XSIZE, - GDI_HEIGHT, TAPE_BUTTON_YSIZE, + GDI_X, VX + pos->x, + GDI_Y, VY + pos->y, + GDI_WIDTH, gfx->width, + GDI_HEIGHT, gfx->height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, GDI_STATE, GD_BUTTON_UNPRESSED, -#if 1 - GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, - GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, -#else - GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y, - GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y, -#endif + GDI_DESIGN_UNPRESSED, gfx->bitmap, gd_x, gd_y, + GDI_DESIGN_PRESSED, gfx->bitmap, gd_xp, gd_yp, GDI_DIRECT_DRAW, FALSE, GDI_EVENT_MASK, GD_EVENT_RELEASED, GDI_CALLBACK_ACTION, HandleTapeButtons, @@ -1508,10 +1577,13 @@ static void HandleTapeButtons(struct GadgetInfo *gi) void HandleTapeButtonKeys(Key key) { - boolean use_extra = (tape.recording || tape.playing); + boolean eject_button_is_active = TAPE_IS_STOPPED(tape); + boolean extra_button_is_active = !eject_button_is_active; - if (key == setup.shortcut.tape_eject) - HandleTapeButtonsExt(use_extra ? TAPE_CTRL_ID_EXTRA : TAPE_CTRL_ID_EJECT); + if (key == setup.shortcut.tape_eject && eject_button_is_active) + HandleTapeButtonsExt(TAPE_CTRL_ID_EJECT); + else if (key == setup.shortcut.tape_extra && extra_button_is_active) + HandleTapeButtonsExt(TAPE_CTRL_ID_EXTRA); else if (key == setup.shortcut.tape_stop) HandleTapeButtonsExt(TAPE_CTRL_ID_STOP); else if (key == setup.shortcut.tape_pause)