void draw_multi_rooms (void) { int x, y; mr_map_rooms (); if (anim_cycle == 0) { generate_wall_colors_for_room (0, room0_wall_color); } if (em == PALACE && vm == VGA && (has_mr_view_changed () || em != mr.last.em || vm != mr.last.vm)) generate_wall_colors (); if (has_mr_view_changed ()) { generate_stars (); generate_mirrors_reflex (); } if (mouse_pos.room != mr.last.mouse_pos.room || mouse_pos.floor != mr.last.mouse_pos.floor || mouse_pos.place != mr.last.mouse_pos.place) { if (is_valid_pos (&mouse_pos)) update_cache_pos (&mouse_pos, em, vm); if (is_valid_pos (&mr.last.mouse_pos)) update_cache_pos (&mr.last.mouse_pos, em, vm); } if (anim_cycle == 0 || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue) { update_room0_cache (em, vm); } if (anim_cycle == 0 || has_mr_view_changed () || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue || level.number != mr.last.level) { update_cache (em, vm); } size_t i; for (i = 0; i < changed_pos_nmemb; i++) { /* printf ("%i,%i,%i\n", changed_pos[i].room, changed_pos[i].floor, changed_pos[i].place); */ update_cache_pos (&changed_pos[i], em, vm); } destroy_array ((void **) &changed_pos, &changed_pos_nmemb); clear_bitmap (screen, BLACK); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_background (mr.cell[x][y].screen, mr.cell[x][y].room); } if (! no_room_drawing) draw_bitmap (cache, screen, 0, 0, 0); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_foreground (mr.cell[x][y].screen, mr.cell[x][y].room); } if (mr.select_cycles > 0) { al_hold_bitmap_drawing (false); int x0 = ORIGINAL_WIDTH * mr.x; int y0 = ROOM_HEIGHT * mr.y + 3; int x1 = x0 + ORIGINAL_WIDTH; int y1 = y0 + ROOM_HEIGHT; draw_rectangle (screen, x0, y0, x1, y1, RED, 1); mr.select_cycles--; } mr.dx = mr.dy = -1; mr_update_last_settings (); }
void flip_display (ALLEGRO_BITMAP *bitmap) { int w = al_get_display_width (display); int h = al_get_display_height (display); int uw = al_get_bitmap_width (uscreen); int uh = al_get_bitmap_height (uscreen); int flags = screen_flags | potion_flags; if (bitmap) { int bw = al_get_bitmap_width (bitmap); int bh = al_get_bitmap_height (bitmap); set_target_backbuffer (display); al_draw_scaled_bitmap (bitmap, 0, 0, bw, bh, 0, 0, w, h, flags); } else { if (has_mr_view_changed () && ! cutscene && ! no_room_drawing) { draw_multi_rooms (); force_full_redraw = true; } int iw = al_get_bitmap_width (iscreen); int ih = al_get_bitmap_height (iscreen); if (iw != w || ih != h) { destroy_bitmap (iscreen); iscreen = clone_bitmap (al_get_backbuffer (display)); } al_set_target_bitmap (iscreen); int x, y; int tw, th; mr_get_resolution (&tw, &th); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { ALLEGRO_BITMAP *screen = (mr.cell[x][y].room || no_room_drawing || cutscene) ? mr.cell[x][y].screen : mr.cell[x][y].cache; int sw = al_get_bitmap_width (screen); int sh = al_get_bitmap_height (screen); float dx = ((ORIGINAL_WIDTH * x) * w) / (float) tw; float dy = ((ROOM_HEIGHT * y) * h) / (float) th; float dw = (sw * w) / (float) tw; float dh = (sh * h) / (float) th; if (cutscene || mr.cell[x][y].room || mr.last.display_width != w || mr.last.display_height != h || force_full_redraw) al_draw_scaled_bitmap (screen, 0, 0, sw, sh, dx, dy, dw, dh, 0); } set_target_backbuffer (display); al_draw_bitmap (iscreen, 0, 0, flags); if (mr.room_select > 0 && ! cutscene) for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) if (mr.cell[x][y].room == mr.room_select) { int rx = x, ry = y; if (flags & ALLEGRO_FLIP_HORIZONTAL) rx = (mr.w - 1) - x; if (flags & ALLEGRO_FLIP_VERTICAL) ry = (mr.h - 1) - y; draw_mr_select_rect (rx, ry, GREEN); } if ((mr.room != mr.last.room || mr.x != mr.last.x || mr.y != mr.last.y || mr.w != mr.last.w || mr.h != mr.last.h) && ! cutscene) mr.select_cycles = SELECT_CYCLES; if (mr.select_cycles > 0 && ! cutscene) { int rx = mr.x, ry = mr.y; if (flags & ALLEGRO_FLIP_HORIZONTAL) rx = (mr.w - 1) - mr.x; if (flags & ALLEGRO_FLIP_VERTICAL) ry = (mr.h - 1) - mr.y; draw_mr_select_rect (rx, ry, RED); if (! pause_anim) mr.select_cycles--; } } al_draw_scaled_bitmap (uscreen, 0, 0, uw, uh, 0, 0, w, h, 0); al_flip_display (); force_full_redraw = false; }
void draw_multi_rooms (void) { int x, y; mr_set_origin (mr.room, mr.x, mr.y); bool mr_view_changed = has_mr_view_changed (); if (mr_view_changed) force_full_redraw = true; if (anim_cycle == 0) { generate_wall_colors_for_room (0, room0_wall_color); } if (em == PALACE && vm == VGA && (mr_view_changed || em != mr.last.em || vm != mr.last.vm)) generate_wall_colors (); if (mr_view_changed) generate_stars (); if (mouse_pos.room != mr.last.mouse_pos.room || mouse_pos.floor != mr.last.mouse_pos.floor || mouse_pos.place != mr.last.mouse_pos.place) { if (is_valid_pos (&mouse_pos)) update_cache_pos (&mouse_pos, CHPOS_MOUSE_SELECT, em, vm); if (is_valid_pos (&mr.last.mouse_pos)) update_cache_pos (&mr.last.mouse_pos, CHPOS_MOUSE_DESELECT, em, vm); } if (anim_cycle == 0 || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue) { update_room0_cache (em, vm); force_full_redraw = true; } if (anim_cycle == 0 || mr_view_changed || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue || global_level.number != mr.last.level) { update_cache (em, vm); } size_t i; for (i = 0; i < changed_pos_nmemb; i++) update_cache_pos (&changed_pos[i].p, changed_pos[i].reason, em, vm); destroy_array ((void **) &changed_pos, &changed_pos_nmemb); for (i = 0; i < changed_room_nmemb; i++) update_cache_room (changed_room[i], em, vm); destroy_array ((void **) &changed_room, &changed_room_nmemb); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { clear_bitmap (mr.cell[x][y].screen, (mr.flicker > 0 && mr.flicker % 2) ? mr.color : BLACK); if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_background (mr.cell[x][y].screen, mr.cell[x][y].room); } if (mr.flicker > 0) mr.flicker--; struct mr_room_list l; mr_get_room_list (&l); int xm, ym; if (! no_room_drawing) for (i = 0; i < l.nmemb; i++) { mr_coord (l.room[i], -1, &xm, &ym); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) if (mr.cell[x][y].room == l.room[i]) draw_bitmap (mr.cell[xm][ym].cache, mr.cell[x][y].screen, 0, 0, 0); } mr_destroy_room_list (&l); /* if (! no_room_drawing) */ /* for (y = mr.h - 1; y >= 0; y--) */ /* for (x = 0; x < mr.w; x++) */ /* if (mr.cell[x][y].room) */ /* draw_bitmap (mr.cell[x][y].cache, mr.cell[x][y].screen, 0, 0, 0); */ for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_foreground (mr.cell[x][y].screen, mr.cell[x][y].room); } /* if (mr.select_cycles > 0) { */ /* int t = max_int (mr.w, mr.h); */ /* draw_rectangle (mr.cell[mr.x][mr.y].screen, 0, 3, */ /* ORIGINAL_WIDTH - t, */ /* 3 + ROOM_HEIGHT - t, RED, t); */ /* mr.select_cycles--; */ /* } */ mr_update_last_settings (); }
void draw_multi_rooms (void) { int x, y; mr_set_origin (mr.room, mr.x, mr.y); bool mr_full_update = has_mr_view_changed () || mr.full_update; if (mr_full_update) { mr_busy (); force_full_redraw = true; } if (anim_cycle == 0) { generate_wall_colors_for_room (0, room0_wall_color); } if (em == PALACE && vm == VGA && (mr_full_update || em != mr.last.em || vm != mr.last.vm)) generate_wall_colors (); if (mouse_pos.room != mr.last.mouse_pos.room || mouse_pos.floor != mr.last.mouse_pos.floor || mouse_pos.place != mr.last.mouse_pos.place) { if (is_valid_pos (&mouse_pos)) register_changed_pos (&mouse_pos); if (is_valid_pos (&mr.last.mouse_pos)) register_changed_pos (&mr.last.mouse_pos); } if (anim_cycle == 0 || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue) { update_room0_cache (em, vm); force_full_redraw = true; } size_t i; if (anim_cycle == 0 || mr_full_update || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue || global_level.n != mr.last.level) { update_cache (em, vm); } else { bool depedv = ((em == DUNGEON && vm == VGA) || (em == DUNGEON && vm == EGA) || (em == PALACE && vm == EGA)); /* optmize changed pos list */ optimize_changed_pos (); /* update cache pos */ for (i = 0; i < changed_pos_nmemb; i++) { update_cache_pos (&changed_pos[i], em, vm); struct pos pl; prel (&changed_pos[i], &pl, +0, -1); if (depedv && fake (&pl) == WALL) update_cache_pos (&pl, em, vm); } /* update cache room */ for (i = 0; i < changed_room_nmemb; i++) update_cache_room (changed_room[i], em, vm); /* kept together so update_cache_pos and update_cache_room can access each other's arrays */ destroy_array ((void **) &changed_pos, &changed_pos_nmemb); destroy_array ((void **) &changed_room, &changed_room_nmemb); } for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { clear_bitmap (mr.cell[x][y].screen, (mr.flicker > 0 && mr.flicker % 2) ? mr.color : BLACK); if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_background (mr.cell[x][y].screen, mr.cell[x][y].room); } if (mr.flicker > 0) mr.flicker--; struct mr_room_list l; mr_get_room_list (&l); int xm, ym; if (! no_room_drawing) for (i = 0; i < l.nmemb; i++) { mr_coord (l.room[i], -1, &xm, &ym); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) if (mr.cell[x][y].room == l.room[i]) draw_bitmap (mr.cell[xm][ym].cache, mr.cell[x][y].screen, 0, 0, 0); } mr_destroy_room_list (&l); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_foreground (mr.cell[x][y].screen, mr.cell[x][y].room); } mr_update_last_settings (); }