void draw_sword (ALLEGRO_BITMAP *bitmap, struct pos *p, enum vm vm, bool start_pos) { ALLEGRO_BITMAP *normal_sword = sword_bitmap (vm), *shiny_sword = shiny_sword_bitmap (vm); if (hgc) { normal_sword = apply_palette (normal_sword, hgc_palette); shiny_sword = apply_palette (shiny_sword, hgc_palette); } if (start_pos) { normal_sword = apply_palette (normal_sword, start_anim_palette); shiny_sword = apply_palette (shiny_sword, start_anim_palette); } struct coord c; ALLEGRO_BITMAP *sword = anim_cycle % 60 ? normal_sword : shiny_sword; seedp (p); draw_bitmapc (sword, bitmap, sword_coord (p, &c), prandom (1) ? ALLEGRO_FLIP_HORIZONTAL : 0); unseedp (); if (! start_pos) { push_clipping_rectangle (bitmap, c.x, c.y, al_get_bitmap_width (sword), al_get_bitmap_height (sword)); draw_confg_fg (bitmap, p, em, vm, NULL); pop_clipping_rectangle (); } }
void draw_randomization (ALLEGRO_BITMAP *bitmap, struct pos *p, enum em em, enum vm vm) { ALLEGRO_BITMAP *wall_narrow_divider = NULL, *wall_wide_divider = NULL; if (vm == VGA) { wall_narrow_divider = apply_hue_palette (dv_wall_narrow_divider); wall_wide_divider = apply_hue_palette (dv_wall_wide_divider); } else if (em == DUNGEON) { wall_narrow_divider = de_wall_narrow_divider; wall_wide_divider = de_wall_wide_divider; } else { wall_narrow_divider = pe_wall_narrow_divider; wall_wide_divider = pe_wall_wide_divider; } if (peq (p, &mouse_pos)) { wall_narrow_divider = apply_palette (wall_narrow_divider, selection_palette); wall_wide_divider = apply_palette (wall_wide_divider, selection_palette); } seedp (p); prandom (1); r0 = prandom(1); r1 = prandom(4); r2 = prandom(1); r3 = prandom(4); wall_divider_00 = r2 ? wall_narrow_divider : wall_wide_divider; wall_divider_01 = r0 ? wall_narrow_divider : wall_wide_divider; enum wall_correlation wc = wall_correlation (p); switch (wc) { case WWW: if (prandom (4) == 0) draw_random_block (bitmap, p, em, vm); draw_divider_01 (bitmap, p, em, vm); draw_divider_00 (bitmap, p, em, vm); if (em == DUNGEON) { if (prandom(4) == 0) draw_right_mark (bitmap, p, prandom (3), vm); if (prandom(4) == 0) draw_left_mark (bitmap, p, prandom (4), vm); } break; case SWS: if (em == DUNGEON && prandom (6) == 0) draw_left_mark (bitmap, p, prandom (1), vm); break; case SWW: if (prandom (4) == 0) draw_random_block (bitmap, p, em, vm); draw_divider_01 (bitmap, p, em, vm); if (em == DUNGEON) { if (prandom(4) == 0) draw_right_mark (bitmap, p, prandom (3), vm); if (prandom(4) == 0) draw_left_mark (bitmap, p, prandom (3), vm); } break; case WWS: draw_divider_01 (bitmap, p, em, vm); draw_divider_00 (bitmap, p, em, vm); if (em == DUNGEON) { if (prandom(4) == 0) draw_right_mark (bitmap, p, prandom (1) + 2, vm); if (prandom(4) == 0) draw_left_mark (bitmap, p, prandom (4), vm); } break; default: error (-1, 0, "%s: unknown wall correlation (%i)", __func__, wc); } unseedp (); }