rix.h 4.1 KB

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