/* _save_switch_state: * Saves the graphics state before a console switch. */ void _save_switch_state(int switch_mode) { BITMAP_INFORMATION *info = info_list; int hadmouse; if (!screen) return; if (_al_linker_mouse && is_same_bitmap(*(_al_linker_mouse->mouse_screen_ptr), screen)) { _al_linker_mouse->show_mouse(NULL); hadmouse = TRUE; } else hadmouse = FALSE; while (info) { save_bitmap_state(info, switch_mode); reconstruct_kids(info->bmp, info->child); info = info->sibling; } _dispsw_status = switch_mode; if (hadmouse) _al_linker_mouse->show_mouse(screen); }
/* psp_do_stretch_blit8: * Hook to capture the call to stretch_blit(). */ void psp_do_stretch_blit8(BITMAP *source, BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked) { source->vtable->do_stretch_blit = NULL; stretch_blit(source, dest, source_x, source_y, source_width, source_height, dest_x, dest_y, dest_width, dest_height); if (is_same_bitmap(dest, displayed_video_bitmap)) psp_draw_to_screen(); source->vtable->do_stretch_blit = psp_do_stretch_blit8; }
/* disable_hardware_cursor: * disables the hardware cursor on platforms where this interferes with * mickeys and disables system cursors. */ void disable_hardware_cursor(void) { if ((mouse_driver) && (mouse_driver->enable_hardware_cursor)) { mouse_driver->enable_hardware_cursor(FALSE); allow_system_cursor = FALSE; if (is_same_bitmap(_mouse_screen, screen)) { BITMAP *bmp = _mouse_screen; show_mouse(NULL); show_mouse(bmp); } } }
/* scare_mouse_area: * Removes the mouse pointer prior to a drawing operation, if that is * required (ie. noop if the mouse is on a memory bitmap, or a hardware * cursor is in use, or the mouse lies outside of the specified bounds * (in this last case, the mouse is frozen)). This operation can later * be reversed by calling unscare_mouse(). */ void scare_mouse_area(int x, int y, int w, int h) { int was_frozen; if (!mouse_driver) return; if ((is_same_bitmap(screen, _mouse_screen)) && (!(gfx_capabilities & GFX_HW_CURSOR))) { was_frozen = freeze_mouse_flag; freeze_mouse_flag = TRUE; if ((mx - mouse_x_focus < x + w) && (my - mouse_y_focus < y + h) && (mx - mouse_x_focus + mouse_sprite->w >= x) && (my - mouse_y_focus + mouse_sprite->h >= y)) { if (scared_size < SCARED_SIZE) { scared_screen[scared_size] = _mouse_screen; scared_freeze[scared_size] = FALSE; } freeze_mouse_flag = was_frozen; show_mouse(NULL); } else { if (scared_size < SCARED_SIZE) { scared_screen[scared_size] = NULL; if (was_frozen) { scared_freeze[scared_size] = FALSE; freeze_mouse_flag = was_frozen; } else scared_freeze[scared_size] = TRUE; } } } else { if (scared_size < SCARED_SIZE) { scared_screen[scared_size] = NULL; scared_freeze[scared_size] = FALSE; } } scared_size++; }
/* scare_mouse: * Removes the mouse pointer prior to a drawing operation, if that is * required (ie. noop if the mouse is on a memory bitmap, or a hardware * cursor is in use). This operation can later be reversed by calling * unscare_mouse(). */ void scare_mouse(void) { if (!mouse_driver) return; if ((is_same_bitmap(screen, _mouse_screen)) && (!(gfx_capabilities & GFX_HW_CURSOR))) { if (scared_size < SCARED_SIZE) { scared_screen[scared_size] = _mouse_screen; scared_freeze[scared_size] = FALSE; } show_mouse(NULL); } else { if (scared_size < SCARED_SIZE) { scared_screen[scared_size] = NULL; scared_freeze[scared_size] = FALSE; } } scared_size++; }
/* _restore_switch_state: * Restores the graphics state after a console switch. */ void _restore_switch_state(void) { BITMAP_INFORMATION *info = info_list; int hadmouse, hadtimer; if (!screen) return; if (_al_linker_mouse && is_same_bitmap(*(_al_linker_mouse->mouse_screen_ptr), screen)) { _al_linker_mouse->show_mouse(NULL); hadmouse = TRUE; } else hadmouse = FALSE; hadtimer = _timer_installed; _timer_installed = FALSE; while (info) { restore_bitmap_state(info); reconstruct_kids(info->bmp, info->child); info = info->sibling; } _dispsw_status = SWITCH_NONE; if (bitmap_color_depth(screen) == 8) { if (_got_prev_current_palette) gfx_driver->set_palette(_prev_current_palette, 0, 255, FALSE); else gfx_driver->set_palette(_current_palette, 0, 255, FALSE); } if (hadmouse) _al_linker_mouse->show_mouse(screen); _timer_installed = hadtimer; }
/* show_mouse: * Tells Allegro to display a mouse pointer. This only works when the timer * module is active. The mouse pointer will be drawn onto the bitmap bmp, * which should normally be the hardware screen. To turn off the mouse * pointer, which you must do before you draw anything onto the screen, call * show_mouse(NULL). If you forget to turn off the mouse pointer when * drawing something, the SVGA bank switching code will become confused and * will produce garbage all over the screen. */ void show_mouse(BITMAP *bmp) { if (!mouse_driver) return; remove_int(mouse_move); /* Remove the mouse cursor */ if (_mouse_screen) { acquire_bitmap(_mouse_screen); if (gfx_capabilities & GFX_HW_CURSOR) { gfx_driver->hide_mouse(); gfx_capabilities &= ~(GFX_HW_CURSOR|GFX_SYSTEM_CURSOR); hw_cursor_dirty = TRUE; } else draw_mouse(TRUE, FALSE); release_bitmap(_mouse_screen); } _mouse_screen = bmp; if (bmp && (current_cursor != MOUSE_CURSOR_NONE)) { acquire_bitmap(_mouse_screen); /* Default system cursor? */ if ((current_cursor != MOUSE_CURSOR_ALLEGRO) && allow_system_cursor) { if (mouse_driver && mouse_driver->select_system_cursor) { use_system_cursor = mouse_driver->select_system_cursor(current_cursor); if (use_system_cursor) { gfx_capabilities |= GFX_HW_CURSOR|GFX_SYSTEM_CURSOR; hw_cursor_dirty = FALSE; got_hw_cursor = TRUE; } } } else { use_system_cursor = FALSE; } /* Custom hardware cursor? */ if (hw_cursor_dirty) { got_hw_cursor = FALSE; if ((gfx_driver) && (gfx_driver->set_mouse_sprite) && (!_dispsw_status)) if (gfx_driver->set_mouse_sprite(mouse_sprite, mouse_x_focus, mouse_y_focus) == 0) got_hw_cursor = TRUE; hw_cursor_dirty = FALSE; } /* Try to display hardware (custom or system) cursor */ if ((got_hw_cursor) && (is_same_bitmap(bmp, screen))) if (gfx_driver->show_mouse(bmp, mx=mouse_x, my=mouse_y) == 0) gfx_capabilities |= GFX_HW_CURSOR; /* Draw cursor manually if we can't do that */ if (!(gfx_capabilities & GFX_HW_CURSOR)) { draw_mouse(FALSE, TRUE); use_system_cursor = FALSE; } release_bitmap(_mouse_screen); install_int(mouse_move, 10); } else { if (mouse_driver->timer_poll) install_int(mouse_move, 10); } }