OEXPMASK.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 : OEXPMASK.CPP
  21. // Description : explored area mask
  22. // Owner : Gilbert
  23. #include <OEXPMASK.h>
  24. #include <OFILE.h>
  25. #include <OWORLDMT.h>
  26. #include <OVGABUF.h>
  27. #include <OSTR.h>
  28. #include <OCOLTBL.h>
  29. #include <OCONFIG.h>
  30. // --------- Define Constant ------//
  31. #define MASK_FILENAME "EXPLMASK.BIN"
  32. #define REMAP_FILENAME "EXPREMAP.BIN"
  33. // no. of darkness scale defined as MAX_BRIGHTNESS_ADJUST_DEGREE in OVGA.H
  34. // ------- Begin of function ExploredMask::init ---------//
  35. void ExploredMask::init(ColorTable *colorTable)
  36. {
  37. brightness_table = colorTable;
  38. // ------- read into exploration mask bitmap --------//
  39. String str;
  40. str = DIR_RES;
  41. str += MASK_FILENAME;
  42. File maskFile;
  43. maskFile.file_open(str);
  44. int fileSize = maskFile.file_size();
  45. mask_bitmap = (char *) mem_add( fileSize );
  46. maskFile.file_read(mask_bitmap, fileSize);
  47. maskFile.file_close();
  48. // ------- read into exploration remap bitmap ------//
  49. str = DIR_RES;
  50. str += REMAP_FILENAME;
  51. File remapFile;
  52. remapFile.file_open(str);
  53. fileSize = remapFile.file_size();
  54. remap_bitmap = (char *) mem_add(fileSize);
  55. remapFile.file_read(remap_bitmap, fileSize);
  56. remapFile.file_close();
  57. }
  58. // ------- End of function ExploredMask::init ---------//
  59. // ------- Begin of function ExploredMask::deinit ---------//
  60. void ExploredMask::deinit()
  61. {
  62. mem_del(mask_bitmap);
  63. mem_del(remap_bitmap);
  64. }
  65. // ------- End of function ExploredMask::deinit ---------//
  66. // ------- Begin of function ExploredMask::draw ---------//
  67. //
  68. // Draw a mask for explored area
  69. // short xLoc, yLoc location of the mask
  70. // int northRow explored flags, bit 0 for northeast square
  71. // bit 1 for north square, bit 2 for northwest square
  72. // int thisRow explored flags, bit 0 for east square
  73. // bit 1 for this square, bit 2 for west square
  74. // int southRow explored flags, bit 0 for southeast square
  75. // bit 1 for south square, bit 2 for southwest square
  76. //
  77. void ExploredMask::draw(short x, short y, int northRow, int thisRow, int southRow)
  78. {
  79. switch(config.explore_mask_method)
  80. {
  81. case 0:
  82. break;
  83. case 1: // use bit masking
  84. vga_back.explore_mask(x, y, mask_bitmap, northRow, thisRow, southRow);
  85. break;
  86. case 2: // use remapping
  87. vga_back.explore_remap(x, y, remap_bitmap, (char **)brightness_table->get_table_array(),
  88. northRow, thisRow, southRow);
  89. break;
  90. default:
  91. err_here();
  92. }
  93. }
  94. // ------- End of function ExploredMask::draw ---------//