rix.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Adplug - Replayer for many OPL2/OPL3 audio file formats.
  3. * Copyright (C) 1999 - 2006 Simon Peter, <dn.tlp@gmx.net>, et al.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. * rix.h - Softstar RIX OPL Format Player by palxex <palxex.ys168.com>
  20. * BSPAL <BSPAL.ys168.com>
  21. */
  22. #include "player.h"
  23. #ifdef _MSC_VER
  24. #include <windows.h>
  25. #define uint8_t BYTE
  26. #define uint16_t WORD
  27. #define uint32_t DWORD
  28. #else
  29. #include <stdint.h>
  30. #endif
  31. class CrixPlayer: public CPlayer
  32. {
  33. public:
  34. static CPlayer *factory(Copl *newopl);
  35. CrixPlayer(Copl *newopl);
  36. ~CrixPlayer();
  37. bool load(const std::string &filename, const CFileProvider &fp);
  38. bool update();
  39. void rewind(int subsong);
  40. float getrefresh();
  41. unsigned int getsubsongs();
  42. std::string gettype()
  43. { return std::string("Softstar RIX OPL Music Format"); };
  44. protected:
  45. typedef struct {
  46. uint8_t v[14];
  47. } ADDT;
  48. int flag_mkf;
  49. uint8_t *file_buffer;
  50. uint8_t *rix_buf; /* rix files' f_buffer */
  51. uint16_t f_buffer[300];//9C0h-C18h
  52. uint16_t a0b0_data2[11];
  53. uint8_t a0b0_data3[18];
  54. uint8_t a0b0_data4[18];
  55. uint8_t a0b0_data5[96];
  56. uint8_t addrs_head[96];
  57. uint16_t insbuf[28];
  58. uint16_t displace[11];
  59. ADDT reg_bufs[18];
  60. uint32_t pos,length;
  61. uint8_t index;
  62. static const uint8_t adflag[18];
  63. static const uint8_t reg_data[18];
  64. static const uint8_t ad_C0_offs[18];
  65. static const uint8_t modify[28];
  66. static const uint8_t bd_reg_data[124];
  67. static uint8_t for40reg[18];
  68. static const uint16_t mus_time;
  69. uint32_t I,T;
  70. uint16_t mus_block;
  71. uint16_t ins_block;
  72. uint8_t rhythm;
  73. uint8_t music_on;
  74. uint8_t pause_flag;
  75. uint16_t band;
  76. uint8_t band_low;
  77. uint16_t e0_reg_flag;
  78. uint8_t bd_modify;
  79. int sustain;
  80. int play_end;
  81. #define ad_08_reg() ad_bop(8,0) /**/
  82. inline void ad_20_reg(uint16_t); /**/
  83. inline void ad_40_reg(uint16_t); /**/
  84. inline void ad_60_reg(uint16_t); /**/
  85. inline void ad_80_reg(uint16_t); /**/
  86. inline void ad_a0b0_reg(uint16_t); /**/
  87. inline void ad_a0b0l_reg(uint16_t,uint16_t,uint16_t); /**/
  88. inline void ad_a0b0l_reg_(uint16_t,uint16_t,uint16_t); /**/
  89. inline void ad_bd_reg(); /**/
  90. inline void ad_bop(uint16_t,uint16_t); /**/
  91. inline void ad_C0_reg(uint16_t); /**/
  92. inline void ad_E0_reg(uint16_t); /**/
  93. inline uint16_t ad_initial(); /**/
  94. inline uint16_t ad_test(); /**/
  95. inline void crc_trans(uint16_t,uint16_t); /**/
  96. inline void data_initial(); /* done */
  97. inline void init(); /**/
  98. inline void ins_to_reg(uint16_t,uint16_t*,uint16_t); /**/
  99. inline void int_08h_entry(); /**/
  100. inline void music_ctrl(); /**/
  101. inline void Pause(); /**/
  102. inline void prepare_a0b0(uint16_t,uint16_t); /**/
  103. inline void rix_90_pro(uint16_t); /**/
  104. inline void rix_A0_pro(uint16_t,uint16_t); /**/
  105. inline void rix_B0_pro(uint16_t,uint16_t); /**/
  106. inline void rix_C0_pro(uint16_t,uint16_t); /**/
  107. inline void rix_get_ins(); /**/
  108. inline uint16_t rix_proc(); /**/
  109. inline void set_new_int();
  110. inline void switch_ad_bd(uint16_t); /**/
  111. };