- frame = SimpleRND(num_frames);
- }
-
- if (mode & ANIM_REVERSE) /* use reverse animation direction */
- frame = num_frames - frame - 1;
-
- return frame;
-}
-
-
-/* ========================================================================= */
-/* toon animation functions */
-/* ========================================================================= */
-
-void InitToonScreen(Bitmap *save_buffer,
- void (*update_function)(void),
- void (*prepare_backbuffer_function)(void),
- boolean (*redraw_needed_function)(void),
- struct ToonInfo *toons, int num_toons,
- int startx, int starty,
- int width, int height,
- int frame_delay_value)
-{
- screen_info.save_buffer = save_buffer;
- screen_info.update_function = update_function;
- screen_info.prepare_backbuffer_function = prepare_backbuffer_function;
- screen_info.redraw_needed_function = redraw_needed_function;
- screen_info.toons = toons;
- screen_info.num_toons = num_toons;
- screen_info.startx = startx;
- screen_info.starty = starty;
- screen_info.width = width;
- screen_info.height = height;
- screen_info.frame_delay_value = frame_delay_value;
-}
-
-void DrawAnim(Bitmap *toon_bitmap, GC toon_clip_gc,
- int src_x, int src_y, int width, int height,
- int dest_x, int dest_y, int pad_x, int pad_y)
-{
- int buf_x = DOOR_GFX_PAGEX3, buf_y = DOOR_GFX_PAGEY1;
-
-#if 1
- /* special method to avoid flickering interference with BackToFront() */
- BlitBitmap(backbuffer, screen_info.save_buffer, dest_x-pad_x, dest_y-pad_y,
- width+2*pad_x, height+2*pad_y, buf_x, buf_y);
- SetClipOrigin(toon_bitmap, toon_clip_gc, dest_x-src_x, dest_y-src_y);
- BlitBitmapMasked(toon_bitmap, backbuffer,
- src_x, src_y, width, height, dest_x, dest_y);
- BlitBitmap(backbuffer, window, dest_x-pad_x, dest_y-pad_y,
- width+2*pad_x, height+2*pad_y, dest_x-pad_x, dest_y-pad_y);
-
- screen_info.update_function();
-
- BlitBitmap(screen_info.save_buffer, backbuffer, buf_x, buf_y,
- width+2*pad_x, height+2*pad_y, dest_x-pad_x, dest_y-pad_y);
-#else
- /* normal method, causing flickering interference with BackToFront() */
- BlitBitmap(backbuffer, screen_info.save_buffer, dest_x-pad_x, dest_y-pad_y,
- width+2*pad_x, height+2*pad_y, buf_x, buf_y);
- SetClipOrigin(toon_bitmap,toon_clip_gc, buf_x-src_x+pad_x,buf_y-src_y+pad_y);
- BlitBitmapMasked(toon_bitmap, screen_info.save_buffer,
- src_x, src_y, width, height, buf_x+pad_x, buf_y+pad_y);
- BlitBitmap(screen_info.save_buffer, window, buf_x, buf_y,
- width+2*pad_x, height+2*pad_y, dest_x-pad_x, dest_y-pad_y);
-#endif
-
- FlushDisplay();
-}
-
-boolean AnimateToon(int toon_nr, boolean restart)
-{
- static unsigned long animation_frame_counter = 0;
- static int pos_x = 0, pos_y = 0;
- static int delta_x = 0, delta_y = 0;
- static int frame = 0;
- static boolean horiz_move, vert_move;
- static unsigned long anim_delay = 0;
- static unsigned long anim_delay_value = 0;
- static int width,height;
- static int pad_x,pad_y;
- static int cut_x,cut_y;
- static int src_x, src_y;
- static int dest_x, dest_y;
- struct ToonInfo *anim = &screen_info.toons[toon_nr];
- Bitmap *anim_bitmap = screen_info.toons[toon_nr].bitmap;
- GC anim_clip_gc = anim_bitmap->stored_clip_gc;
-
- if (restart)
- {
- horiz_move = (anim->direction & (ANIMDIR_LEFT | ANIMDIR_RIGHT));
- vert_move = (anim->direction & (ANIMDIR_UP | ANIMDIR_DOWN));
- anim_delay_value = anim->move_delay * screen_info.frame_delay_value;
-
- frame = getAnimationFrame(anim->anim_frames, anim->anim_delay,
- anim->anim_mode, anim->start_frame,
- animation_frame_counter++);
-
- if (horiz_move)
- {
- if (anim->position == ANIMPOS_UP)
- pos_y = 0;
- else if (anim->position == ANIMPOS_DOWN)
- pos_y = screen_info.height - anim->height;
- else if (anim->position == ANIMPOS_UPPER)
- pos_y = SimpleRND((screen_info.height - anim->height) / 2);
- else
- pos_y = SimpleRND(screen_info.height - anim->height);
-
- if (anim->direction == ANIMDIR_RIGHT)
- {
- delta_x = anim->stepsize;
- pos_x = -anim->width + delta_x;
- }
- else
- {
- delta_x = -anim->stepsize;
- pos_x = screen_info.width + delta_x;
- }
- delta_y = 0;
- }