OVGA2.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OVGA2.CPP
  21. //Description: Functions for display big image
  22. #include <OSTR.h>
  23. #include <OSYS.h>
  24. #include <OFILE.h>
  25. #include <OMOUSE.h>
  26. #include <OVGALOCK.h>
  27. #include <OVGA.h>
  28. //---------- Begin of function Vga::disp_image_file --------//
  29. //
  30. // <char*> fileName - file name of the image
  31. // [int] x1, y1 - the top left display position of the image
  32. // (default: 0)
  33. //
  34. void Vga::disp_image_file(char* fileName, int x1, int y1)
  35. {
  36. //-------- backup and switch palette ----------//
  37. if( !back_up_pal ) // only save the palette when there isn't one saved already
  38. back_up_pal = new VgaCustomPalette(NULL);
  39. //---- load the interface into the back buffer ----//
  40. File pictFile;
  41. String str;
  42. str = DIR_IMAGE;
  43. str += fileName;
  44. str += ".ICN";
  45. if( pictFile.file_open(str,0) )
  46. {
  47. vga_back.put_large_bitmap(x1, y1, &pictFile);
  48. pictFile.file_close();
  49. }
  50. //-------- hide and change mouse cursor --------//
  51. mouse.hide();
  52. //------ turn screen dark and blt the buffer ---------//
  53. vga_front.bar( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 );
  54. sys.blt_virtual_buf();
  55. //------- Set custom palette -------//
  56. {
  57. str = DIR_IMAGE;
  58. str += fileName;
  59. str += ".COL";
  60. err_when( !m.is_file_exist(str) );
  61. VgaFrontLock vgaLock;
  62. VgaCustomPalette::set_custom_palette(str);
  63. }
  64. //------- bilt the back buffer to the front ---------//
  65. vga.blt_buf( 0,0, vga_back.buf_width()-1, vga_back.buf_height()-1, 0 );
  66. }
  67. //----------- End of function Vga::disp_image_file ---------//
  68. //---------- Begin of function Vga::finish_disp_image_file --------//
  69. //
  70. void Vga::finish_disp_image_file()
  71. {
  72. //------- exiting: turn dark --------//
  73. vga_front.bar( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 );
  74. sys.blt_virtual_buf();
  75. //----- palette restore when back_up_pal destruct ----//
  76. {
  77. VgaFrontLock vgaLock;
  78. err_when( !back_up_pal );
  79. delete back_up_pal;
  80. back_up_pal = NULL;
  81. }
  82. mouse.show();
  83. }
  84. //----------- End of function Vga::finish_disp_image_file ---------//