OSE.h 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 : OSE.H
  21. // Description: Header file of Sound Effect Controller
  22. // Owner : Gilbert
  23. #ifndef __OSE_H
  24. #define __OSE_H
  25. #include <ORESX.h>
  26. #include <OVOLUME.h>
  27. // ------ Define sound effect no. ------//
  28. // note : wave file should be less than 64k in size, otherwise
  29. // the offset generated by LIBxxx.EXE is not correct
  30. //
  31. // ------ Define constant -------//
  32. #define MAX_SE_CACHED 32
  33. // a no. of sound effect is taken care for those are requested
  34. // this cycle or last cycle
  35. // ------ Define Struct SERequest ------//
  36. #define MAX_SE_STORE 4
  37. struct SERequest
  38. {
  39. char *wave_ptr;
  40. short resx_id;
  41. short req_used;
  42. RelVolume play_vol[MAX_SE_STORE];
  43. void add_request(RelVolume);
  44. int max_entry();
  45. void remove_request(int slot);
  46. void clear_request();
  47. };
  48. // ------ Define Class SECtrl -------//
  49. class Audio;
  50. class SECtrl
  51. {
  52. private:
  53. int biased_se;
  54. SERequest *req_pool;
  55. char *last_cycle;
  56. int cached_size;
  57. short cached_index[MAX_SE_CACHED];
  58. public:
  59. int init_flag;
  60. int audio_flag; // set if audio.wav_init_flag is set during init
  61. int max_sound_effect;
  62. int max_supp_effect;
  63. int total_effect;
  64. Audio *audio_ptr;
  65. ResourceIdx res_wave;
  66. ResourceIdx &res_supp;
  67. public:
  68. SECtrl(Audio *);
  69. ~SECtrl();
  70. void init();
  71. void deinit();
  72. void request( int soundEffect, RelVolume );
  73. void request( char *soundName, RelVolume );
  74. // volume between 0 to 100; pan between -10,000=left, 10,000=right
  75. void flush(); // output sound effect to volume
  76. void clear();
  77. char *get_effect_name(int);
  78. int search_effect_id(char *);
  79. int search_effect_id(char *, int len);
  80. int immediate_sound( char *soundName, RelVolume=DEF_REL_VOLUME); // mainly for button sound, interface
  81. // static long sound_volume(short locX, short locY);
  82. // static long sound_volume(short locX, short locY, short limit, short drop);
  83. // static long sound_pan(short locX, short locY);
  84. // static long sound_pan(short locX, short locY, short drop);
  85. private:
  86. void load_info();
  87. };
  88. extern SECtrl se_ctrl;
  89. #endif