rix.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. #if defined(_MSC_VER) && _MSC_VER <= 1600
  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) { rewind(subsong, true); }
  40. void rewind(int subsong, bool reinit); /* For seamless continous */
  41. float getrefresh();
  42. unsigned int getsubsongs();
  43. std::string gettype()
  44. { return std::string("Softstar RIX OPL Music Format"); };
  45. #if USE_RIX_EXTRA_INIT
  46. void set_extra_init(uint32_t* regs, uint8_t* datas, int n);
  47. #endif
  48. protected:
  49. typedef struct {
  50. uint8_t v[14];
  51. } ADDT;
  52. int flag_mkf;
  53. #if USE_RIX_EXTRA_INIT
  54. uint32_t *extra_regs;
  55. uint8_t *extra_vals;
  56. #endif
  57. uint8_t *file_buffer;
  58. uint8_t *rix_buf; /* rix files' f_buffer */
  59. uint16_t f_buffer[300];//9C0h-C18h
  60. uint16_t a0b0_data2[11];
  61. uint8_t a0b0_data3[18];
  62. uint8_t a0b0_data4[18];
  63. uint8_t a0b0_data5[96];
  64. uint8_t addrs_head[96];
  65. uint16_t insbuf[28];
  66. uint16_t displace[11];
  67. ADDT reg_bufs[18];
  68. uint32_t pos, length;
  69. #if USE_RIX_EXTRA_INIT
  70. uint32_t extra_length;
  71. #endif
  72. static const uint8_t adflag[18];
  73. static const uint8_t reg_data[18];
  74. static const uint8_t ad_C0_offs[18];
  75. static const uint8_t modify[28];
  76. static const uint8_t bd_reg_data[124];
  77. static uint8_t for40reg[18];
  78. static const uint16_t mus_time;
  79. uint32_t I,T;
  80. uint16_t mus_block;
  81. uint16_t ins_block;
  82. uint8_t rhythm;
  83. uint8_t music_on;
  84. uint8_t pause_flag;
  85. uint16_t band;
  86. uint8_t band_low;
  87. uint16_t e0_reg_flag;
  88. uint8_t bd_modify;
  89. int sustain;
  90. int play_end;
  91. #define ad_08_reg() ad_bop(8,0) /**/
  92. inline void ad_20_reg(uint16_t); /**/
  93. inline void ad_40_reg(uint16_t); /**/
  94. inline void ad_60_reg(uint16_t); /**/
  95. inline void ad_80_reg(uint16_t); /**/
  96. inline void ad_a0b0_reg(uint16_t); /**/
  97. inline void ad_a0b0l_reg(uint16_t,uint16_t,uint16_t); /**/
  98. inline void ad_a0b0l_reg_(uint16_t,uint16_t,uint16_t); /**/
  99. inline void ad_bd_reg(); /**/
  100. inline void ad_bop(uint16_t,uint16_t); /**/
  101. inline void ad_C0_reg(uint16_t); /**/
  102. inline void ad_E0_reg(uint16_t); /**/
  103. inline uint16_t ad_initial(); /**/
  104. inline uint16_t ad_test(); /**/
  105. inline void crc_trans(uint16_t,uint16_t); /**/
  106. inline void data_initial(); /* done */
  107. inline void init(); /**/
  108. inline void ins_to_reg(uint16_t,uint16_t*,uint16_t); /**/
  109. inline void int_08h_entry(); /**/
  110. inline void music_ctrl(); /**/
  111. inline void Pause(); /**/
  112. inline void prepare_a0b0(uint16_t,uint16_t); /**/
  113. inline void rix_90_pro(uint16_t); /**/
  114. inline void rix_A0_pro(uint16_t,uint16_t); /**/
  115. inline void rix_B0_pro(uint16_t,uint16_t); /**/
  116. inline void rix_C0_pro(uint16_t,uint16_t); /**/
  117. inline void rix_get_ins(); /**/
  118. inline uint16_t rix_proc(); /**/
  119. inline void set_new_int();
  120. inline void switch_ad_bd(uint16_t); /**/
  121. };