rix.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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);
  40. void rewindReInit(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. FILE *fp;
  58. int subsongs;
  59. uint8_t rix_buf[16384]; /* rix files' f_buffer */
  60. uint16_t f_buffer[300];//9C0h-C18h
  61. uint16_t a0b0_data2[11];
  62. uint8_t a0b0_data3[18];
  63. uint8_t a0b0_data4[18];
  64. uint8_t a0b0_data5[96];
  65. uint8_t addrs_head[96];
  66. uint16_t insbuf[28];
  67. uint16_t displace[11];
  68. ADDT reg_bufs[18];
  69. uint32_t pos, length;
  70. #if USE_RIX_EXTRA_INIT
  71. uint32_t extra_length;
  72. #endif
  73. static const uint8_t adflag[18];
  74. static const uint8_t reg_data[18];
  75. static const uint8_t ad_C0_offs[18];
  76. static const uint8_t modify[28];
  77. static const uint8_t bd_reg_data[124];
  78. static uint8_t for40reg[18];
  79. static const uint16_t mus_time;
  80. uint32_t I,T;
  81. uint16_t mus_block;
  82. uint16_t ins_block;
  83. uint8_t rhythm;
  84. uint8_t music_on;
  85. uint8_t pause_flag;
  86. uint16_t band;
  87. uint8_t band_low;
  88. uint16_t e0_reg_flag;
  89. uint8_t bd_modify;
  90. int sustain;
  91. int play_end;
  92. #define ad_08_reg() ad_bop(8,0) /**/
  93. void ad_20_reg(uint16_t); /**/
  94. void ad_40_reg(uint16_t); /**/
  95. void ad_60_reg(uint16_t); /**/
  96. void ad_80_reg(uint16_t); /**/
  97. void ad_a0b0_reg(uint16_t); /**/
  98. void ad_a0b0l_reg(uint16_t,uint16_t,uint16_t); /**/
  99. void ad_a0b0l_reg_(uint16_t,uint16_t,uint16_t); /**/
  100. void ad_bd_reg(); /**/
  101. void ad_bop(uint16_t,uint16_t); /**/
  102. void ad_C0_reg(uint16_t); /**/
  103. void ad_E0_reg(uint16_t); /**/
  104. uint16_t ad_initial(); /**/
  105. uint16_t ad_test(); /**/
  106. void crc_trans(uint16_t,uint16_t); /**/
  107. void data_initial(); /* done */
  108. void init(); /**/
  109. void ins_to_reg(uint16_t,uint16_t*,uint16_t); /**/
  110. void int_08h_entry(); /**/
  111. void music_ctrl(); /**/
  112. void Pause(); /**/
  113. void prepare_a0b0(uint16_t,uint16_t); /**/
  114. void rix_90_pro(uint16_t); /**/
  115. void rix_A0_pro(uint16_t,uint16_t); /**/
  116. void rix_B0_pro(uint16_t,uint16_t); /**/
  117. void rix_C0_pro(uint16_t,uint16_t); /**/
  118. void rix_get_ins(); /**/
  119. uint16_t rix_proc(); /**/
  120. void set_new_int();
  121. void switch_ad_bd(uint16_t); /**/
  122. };