Mercurial > audlegacy
changeset 637:2b06eb5e472d trunk
[svn] Sync with upstream. Drop hardware OPL2/3 support, it throws warnings and is not used on most modern machines. Added var inits where GCC 4.0 thought it was a good idea.
author | chainsaw |
---|---|
date | Sat, 18 Feb 2006 08:23:30 -0800 |
parents | aa6914ee37ab |
children | 72ec4db929ed |
files | Plugins/Input/adplug/core/Makefile.in Plugins/Input/adplug/core/analopl.cpp Plugins/Input/adplug/core/analopl.h Plugins/Input/adplug/core/database.cpp Plugins/Input/adplug/core/imf.cpp Plugins/Input/adplug/core/imf.h Plugins/Input/adplug/core/ksm.cpp Plugins/Input/adplug/core/msc.cpp Plugins/Input/adplug/core/realopl.cpp Plugins/Input/adplug/core/realopl.h Plugins/Input/adplug/core/rix.cpp Plugins/Input/adplug/core/rix.h Plugins/Input/adplug/core/u6m.cpp |
diffstat | 13 files changed, 464 insertions(+), 834 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Input/adplug/core/Makefile.in Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/Makefile.in Sat Feb 18 08:23:30 2006 -0800 @@ -3,20 +3,19 @@ OBJECTIVE_LIBS_NOINST = libadplugcore.a -SOURCES = adplug.cpp emuopl.cpp fmopl.c diskopl.cpp debug.c \ -fprovide.cpp player.cpp database.cpp hsc.cpp sng.cpp imf.cpp \ -players.cpp protrack.cpp a2m.cpp adtrack.cpp amd.cpp bam.cpp d00.cpp dfm.cpp dmo.cpp \ -hsp.cpp ksm.cpp mad.cpp mid.cpp mkj.cpp cff.cpp dtm.cpp fmc.cpp mtk.cpp rad.cpp raw.cpp \ -sa2.cpp s3m.cpp xad.cpp flash.cpp bmf.cpp hybrid.cpp hyp.cpp psi.cpp rat.cpp u6m.cpp \ -rol.cpp xsm.cpp adlibemu.c dro.cpp lds.cpp realopl.cpp analopl.cpp \ -temuopl.cpp msc.cpp rix.cpp +SOURCES = adplug.cpp emuopl.cpp fmopl.c diskopl.cpp debug.c fprovide.cpp \ +player.cpp database.cpp hsc.cpp sng.cpp imf.cpp players.cpp protrack.cpp \ +a2m.cpp adtrack.cpp amd.cpp bam.cpp d00.cpp dfm.cpp dmo.cpp hsp.cpp ksm.cpp \ +mad.cpp mid.cpp mkj.cpp cff.cpp dtm.cpp fmc.cpp mtk.cpp rad.cpp raw.cpp \ +sa2.cpp s3m.cpp xad.cpp flash.cpp bmf.cpp hybrid.cpp hyp.cpp psi.cpp rat.cpp \ +u6m.cpp rol.cpp xsm.cpp adlibemu.c dro.cpp lds.cpp temuopl.cpp msc.cpp rix.cpp noinst_HEADERS = adplug.h emuopl.h fmopl.h silentopl.h opl.h diskopl.h \ a2m.h amd.h bam.h d00.h dfm.h hsc.h hsp.h imf.h ksm.h lds.h mid.h mkj.h mtk.h \ protrack.h rad.h raw.h sa2.h sng.h u6m.h player.h fmc.h mad.h xad.h bmf.h \ flash.h hyp.h psi.h rat.h hybrid.h rol.h adtrack.h cff.h dtm.h fprovide.h \ -database.h players.h xsm.h adlibemu.h kemuopl.h dro.h dmo.h s3m.h realopl.h \ -analopl.h temuopl.h msc.h rix.h +database.h players.h xsm.h adlibemu.h kemuopl.h dro.h dmo.h s3m.h temuopl.h \ +msc.h rix.h CFLAGS += -fPIC -DPIC $(BINIO_CFLAGS) -I../../../../intl -I../../../.. CXXFLAGS = $(CFLAGS) -Dstricmp=strcasecmp
--- a/Plugins/Input/adplug/core/analopl.cpp Thu Feb 16 07:40:35 2006 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * analopl.cpp - Spectrum analyzing hardware OPL, by Simon Peter <dn.tlp@gmx.net> - */ - -#include "analopl.h" - -CAnalopl::CAnalopl(unsigned short initport) - : CRealopl(initport) -{ - for(int i = 0; i < 9; i++) { - keyregs[0][i][0] = 0; - keyregs[0][i][1] = 0; - keyregs[1][i][0] = 0; - keyregs[1][i][1] = 0; - } -} - -void CAnalopl::write(int reg, int val) -{ - if(nowrite) return; - - if(reg >= 0xb0 && reg <= 0xb8) { - if(!keyregs[currChip][reg - 0xb0][0] && (val & 32)) - keyregs[currChip][reg - 0xb0][1] = 1; - else - keyregs[currChip][reg - 0xb0][1] = 0; - keyregs[currChip][reg - 0xb0][0] = val & 32; - } - - CRealopl::write(reg, val); -} - -int CAnalopl::getcarriervol(unsigned int v, unsigned int c) -{ - return (hardvols[c][op_table[v]+3][0] & 63); -} - -int CAnalopl::getmodulatorvol(unsigned int v, unsigned int c) -{ - return (hardvols[c][op_table[v]][0] & 63); -} - -bool CAnalopl::getkeyon(unsigned int v, unsigned int c) -{ - if(keyregs[c][v][1]) { - keyregs[c][v][1] = 0; - return true; - } else - return false; -}
--- a/Plugins/Input/adplug/core/analopl.h Thu Feb 16 07:40:35 2006 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * analopl.h - Spectrum analyzing hardware OPL, by Simon Peter <dn.tlp@gmx.net> - */ - -#ifndef H_ADPLUG_ANALOPL -#define H_ADPLUG_ANALOPL - -#include "realopl.h" - -class CAnalopl: public CRealopl -{ - public: - CAnalopl(unsigned short initport = DFL_ADLIBPORT); // initport = OPL2 hardware baseport - - // get carrier volume of adlib voice v on chip c - int getcarriervol(unsigned int v, unsigned int c = 0); - // get modulator volume of adlib voice v on chip c - int getmodulatorvol(unsigned int v, unsigned int c = 0); - bool getkeyon(unsigned int v, unsigned int c = 0); - - void write(int reg, int val); - - protected: - unsigned char keyregs[2][9][2]; // shadow key register -}; - -#endif
--- a/Plugins/Input/adplug/core/database.cpp Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/database.cpp Sat Feb 18 08:23:30 2006 -0800 @@ -1,6 +1,6 @@ /* * AdPlug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (c) 1999 - 2003 Simon Peter <dn.tlp@gmx.net>, et al. + * Copyright (c) 1999 - 2006 Simon Peter <dn.tlp@gmx.net>, et al. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,7 +18,7 @@ * * database.cpp - AdPlug database class * Copyright (c) 2002 Riven the Mage <riven@ok.ru> - * Copyright (c) 2002, 2003 Simon Peter <dn.tlp@gmx.net> + * Copyright (c) 2002, 2003, 2006 Simon Peter <dn.tlp@gmx.net> */ #include <binio.h> @@ -95,6 +95,9 @@ { unsigned long i; + // Save database as little endian with IEEE floats + f.setFlag(binio::BigEndian, false); f.setFlag(binio::FloatIEEE); + f.writeString(DB_FILEID_V10); f.writeInt(linear_logic_length, 4);
--- a/Plugins/Input/adplug/core/imf.cpp Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/imf.cpp Sat Feb 18 08:23:30 2006 -0800 @@ -1,6 +1,6 @@ /* * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter <dn.tlp@gmx.net>, et al. + * Copyright (C) 1999 - 2006 Simon Peter <dn.tlp@gmx.net>, et al. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,6 +35,10 @@ * type, invented by Martin Fernandez <mfernan@cnba.uba.ar>, that's got a * proper header to add title/game name information. After the header starts * the normal IMF file in one of the two above mentioned formats. + * + * This player also handles a special footer format by Adam Nielsen, + * which has defined fields of information about the song, the author + * and more. */ #include <string.h> @@ -116,7 +120,7 @@ footer[footerlen] = '\0'; // Make ASCIIZ string } - rate = getrate(f); + rate = getrate(filename, fp, f); fp.close(f); rewind(0); return true; @@ -176,16 +180,17 @@ /*** private methods *************************************/ -float CimfPlayer::getrate(binistream *f) +float CimfPlayer::getrate(const std::string &filename, const CFileProvider &fp, binistream *f) { - if(!db) return 700.0f; // Database offline - - f->seek(0, binio::Set); + if(db) { // Database available + f->seek(0, binio::Set); + CClockRecord *record = (CClockRecord *)db->search(CAdPlugDatabase::CKey(*f)); + if (record && record->type == CAdPlugDatabase::CRecord::ClockSpeed) + return record->clock; + } - CClockRecord *record = (CClockRecord *)db->search(CAdPlugDatabase::CKey(*f)); - - if(!record || record->type != CAdPlugDatabase::CRecord::ClockSpeed) - return 700.0f; - else - return record->clock; + // Otherwise the database is either unavailable, or there's no entry for this file + if (fp.extension(filename, ".imf")) return 560.0f; + if (fp.extension(filename, ".wlf")) return 700.0f; + return 700.0f; // default speed for unknown files that aren't .IMF or .WLF }
--- a/Plugins/Input/adplug/core/imf.h Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/imf.h Sat Feb 18 08:23:30 2006 -0800 @@ -62,7 +62,7 @@ } *data; private: - float getrate(binistream *f); + float getrate(const std::string &filename, const CFileProvider &fp, binistream *f); }; #endif
--- a/Plugins/Input/adplug/core/ksm.cpp Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/ksm.cpp Sat Feb 18 08:23:30 2006 -0800 @@ -97,7 +97,7 @@ bool CksmPlayer::update() { - int quanter,chan,drumnum,freq,track,volevel,volval; + int quanter,chan=0,drumnum=0,freq,track,volevel,volval; unsigned int i,j,bufnum; unsigned long temp,templong;
--- a/Plugins/Input/adplug/core/msc.cpp Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/msc.cpp Sat Feb 18 08:23:30 2006 -0800 @@ -225,7 +225,7 @@ blk = msc_data [block_num]; while (1) { u8 octet; // decoded octet - u8 len_corr; // length correction + u8 len_corr = 0; // length correction // advance to next block if necessary if (block_pos >= blk.mb_length && dec_len == 0) {
--- a/Plugins/Input/adplug/core/realopl.cpp Thu Feb 16 07:40:35 2006 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -/* - * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * realopl.cpp - Real hardware OPL, by Simon Peter <dn.tlp@gmx.net> - */ - -#ifdef _MSC_VER // Microsoft Visual C++ -# include <conio.h> -# define INP _inp -# define OUTP _outp -#elif defined(__WATCOMC__) // Watcom C/C++ and OpenWatcom -# include <conio.h> -# define INP inp -# define OUTP outp -#elif defined(WIN32) && defined(__MSVCRT__) && defined(__MINGW32__) -/* -int __cdecl _inp(unsigned short); -int __cdecl _outp(unsigned short, int); -# define INP _inp -# define OUTP _outp -*/ -# define INP inb -# define OUTP(reg, val) outb(val, reg) -#else // no support on other platforms -# define INP(reg) 0 -# define OUTP(reg, val) -#endif - -#include "realopl.h" - -#define SHORTDELAY 6 // short delay in I/O port-reads after OPL hardware output -#define LONGDELAY 35 // long delay in I/O port-reads after OPL hardware output - -const unsigned char CRealopl::op_table[9] = - {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12}; - -#if defined(WIN32) && defined(__MINGW32__) -static __inline unsigned char -inb (unsigned short int port) -{ - unsigned char _v; - - __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline void -outb (unsigned char value, unsigned short int port) -{ - __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); -} -#endif - -CRealopl::CRealopl(unsigned short initport) - : adlport(initport), hardvol(0), bequiet(false), nowrite(false) -{ - for(int i=0;i<22;i++) { - hardvols[0][i][0] = 0; - hardvols[0][i][1] = 0; - hardvols[1][i][0] = 0; - hardvols[1][i][1] = 0; - } - - currType = TYPE_OPL3; -} - -bool CRealopl::harddetect() -{ - unsigned char stat1, stat2, i; - unsigned short adp = (currChip == 0 ? adlport : adlport + 2); - - hardwrite(4,0x60); hardwrite(4,0x80); - stat1 = INP(adp); - hardwrite(2,0xff); hardwrite(4,0x21); -#if INP != 0 - for(i=0;i<80;i++) // wait for adlib - INP(adp); -#endif - stat2 = INP(adp); - hardwrite(4,0x60); hardwrite(4,0x80); - - if(((stat1 & 0xe0) == 0) && ((stat2 & 0xe0) == 0xc0)) - return true; - else - return false; -} - -bool CRealopl::detect() -{ - unsigned char stat; - - setchip(0); - if(harddetect()) { - // is at least OPL2, check for OPL3 - currType = TYPE_OPL2; - - stat = INP(adlport); - if(stat & 6) { - // not OPL3, try dual-OPL2 - setchip(1); - if(harddetect()) - currType = TYPE_DUAL_OPL2; - } else - currType = TYPE_OPL3; - - setchip(0); - return true; - } else - return false; -} - -void CRealopl::setvolume(int volume) -{ - int i, j; - - hardvol = volume; - for(j = 0; j < 2; j++) - for(i = 0; i < 9; i++) { - hardwrite(0x43+op_table[i],((hardvols[j][op_table[i]+3][0] & 63) + volume) > 63 ? 63 : hardvols[j][op_table[i]+3][0] + volume); - if(hardvols[j][i][1] & 1) // modulator too? - hardwrite(0x40+op_table[i],((hardvols[j][op_table[i]][0] & 63) + volume) > 63 ? 63 : hardvols[j][op_table[i]][0] + volume); - } -} - -void CRealopl::setquiet(bool quiet) -{ - bequiet = quiet; - - if(quiet) { - oldvol = hardvol; - setvolume(63); - } else - setvolume(oldvol); -} - -void CRealopl::hardwrite(int reg, int val) -{ - int i; - unsigned short adp = (currChip == 0 ? adlport : adlport + 2); - - OUTP(adp,reg); // set register -#if INP != 0 - for(i=0;i<SHORTDELAY;i++) // wait for adlib - INP(adp); - OUTP(adp+1,val); // set value - for(i=0;i<LONGDELAY;i++) // wait for adlib - INP(adp); -#endif -} - -void CRealopl::write(int reg, int val) -{ - int i; - - if(nowrite) - return; - - if(currType == TYPE_OPL2 && currChip > 0) - return; - - if(bequiet && (reg >= 0xb0 && reg <= 0xb8)) // filter all key-on commands - val &= ~32; - if(reg >= 0x40 && reg <= 0x55) // cache volumes - hardvols[currChip][reg-0x40][0] = val; - if(reg >= 0xc0 && reg <= 0xc8) - hardvols[currChip][reg-0xc0][1] = val; - if(hardvol) // reduce volume - for(i=0;i<9;i++) { - if(reg == 0x43 + op_table[i]) - val = ((val & 63) + hardvol) > 63 ? 63 : val + hardvol; - else - if((reg == 0x40 + op_table[i]) && (hardvols[currChip][i][1] & 1)) - val = ((val & 63) + hardvol) > 63 ? 63 : val + hardvol; - } - - hardwrite(reg,val); -} - -void CRealopl::init() -{ - int i, j; - - for(j = 0; j < 2; j++) { - setchip(j); - - for(i=0;i<9;i++) { // stop instruments - hardwrite(0xb0 + i,0); // key off - hardwrite(0x80 + op_table[i],0xff); // fastest release - } - - hardwrite(0xbd,0); // clear misc. register - } -}
--- a/Plugins/Input/adplug/core/realopl.h Thu Feb 16 07:40:35 2006 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * AdPlug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter <dn.tlp@gmx.net>, et al. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * realopl.h - Real hardware OPL, by Simon Peter <dn.tlp@gmx.net> - */ - -#ifndef H_ADPLUG_REALOPL -#define H_ADPLUG_REALOPL - -#include "opl.h" - -#define DFL_ADLIBPORT 0x388 // default adlib baseport - -class CRealopl: public Copl -{ - public: - CRealopl(unsigned short initport = DFL_ADLIBPORT); // initport = OPL2 hardware baseport - - bool detect(); // returns true if adlib compatible board is found, else false - void setvolume(int volume); // set adlib master volume (0 - 63) 0 = loudest, 63 = softest - void setquiet(bool quiet = true); // sets the OPL2 quiet, while still writing to the registers - void setport(unsigned short port) // set new OPL2 hardware baseport - { - adlport = port; - } - void setnowrite(bool nw = true) // set hardware write status - { - nowrite = nw; - } - - int getvolume() // get adlib master volume - { - return hardvol; - } - - // template methods - void write(int reg, int val); - void init(); - void settype(ChipType type) - { - currType = type; - } - - protected: - void hardwrite(int reg, int val); // write to OPL2 hardware registers - bool harddetect(); // do real hardware detection - - static const unsigned char op_table[9]; // the 9 operators as expected by the OPL2 - - unsigned short adlport; // adlib hardware baseport - int hardvol, oldvol; // hardware master volume - bool bequiet; // quiet status cache - char hardvols[2][22][2]; // volume cache - bool nowrite; // don't write to hardware, if true -}; - -#endif
--- a/Plugins/Input/adplug/core/rix.cpp Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/rix.cpp Sat Feb 18 08:23:30 2006 -0800 @@ -1,6 +1,6 @@ /* * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al. + * Copyright (C) 1999 - 2006 Simon Peter, <dn.tlp@gmx.net>, et al. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,148 +26,174 @@ const unsigned char CrixPlayer::reg_data[] = {0,1,2,3,4,5,8,9,10,11,12,13,16,17,18,19,20,21}; const unsigned char CrixPlayer::ad_C0_offs[] = {0,1,2,0,1,2,3,4,5,3,4,5,6,7,8,6,7,8}; const unsigned char CrixPlayer::modify[] = {0,3,1,4,2,5,6,9,7,10,8,11,12,15,13,16,14,17,12,\ - 15,16,0,14,0,17,0,13,0}; -const unsigned char CrixPlayer::bd_reg_data[] = {\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0x04,0x02,0x01,\ - 0x00,0x01,0x01,0x03,0x0F,0x05,0x00,0x01,0x03,0x0F,0x00,\ - 0x00,0x00,0x01,0x00,0x00,0x01,0x01,0x0F,0x07,0x00,0x02,\ - 0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x0A,\ - 0x04,0x00,0x08,0x0C,0x0B,0x00,0x00,0x00,0x01,0x00,0x00,\ - 0x00,0x00,0x0D,0x04,0x00,0x06,0x0F,0x00,0x00,0x00,0x00,\ - 0x01,0x00,0x00,0x0C,0x00,0x0F,0x0B,0x00,0x08,0x05,0x00,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x0F,0x0B,0x00,\ - 0x07,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,\ - 0x0F,0x0B,0x00,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x01,0x00,0x0F,0x0B,0x00,0x07,0x05,0x00,0x00,0x00,\ - 0x00,0x00,0x00}; -unsigned char CrixPlayer::for40reg[] = {0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,\ - 0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F}; + 15,16,0,14,0,17,0,13,0}; +const unsigned char CrixPlayer::bd_reg_data[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0x04,0x02,0x01, + 0x00,0x01,0x01,0x03,0x0F,0x05,0x00,0x01,0x03,0x0F,0x00, + 0x00,0x00,0x01,0x00,0x00,0x01,0x01,0x0F,0x07,0x00,0x02, + 0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x0A, + 0x04,0x00,0x08,0x0C,0x0B,0x00,0x00,0x00,0x01,0x00,0x00, + 0x00,0x00,0x0D,0x04,0x00,0x06,0x0F,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x0C,0x00,0x0F,0x0B,0x00,0x08,0x05,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x0F,0x0B,0x00, + 0x07,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, + 0x0F,0x0B,0x00,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x01,0x00,0x0F,0x0B,0x00,0x07,0x05,0x00,0x00,0x00, + 0x00,0x00,0x00}; +unsigned char CrixPlayer::for40reg[] = {0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F, + 0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F}; unsigned short CrixPlayer::mus_time = 0x4268; + /*** public methods *************************************/ + CPlayer *CrixPlayer::factory(Copl *newopl) { return new CrixPlayer(newopl); } +CrixPlayer::CrixPlayer(Copl *newopl) + : CPlayer(newopl),I(0),T(0),mus_block(0),ins_block(0),rhythm(0),mutex(0), + music_on(0),pause_flag(0),band(0),band_low(0),e0_reg_flag(0),bd_modify(0), + sustain(0),dro_end(0), mstotal(0), opl3_mode(0) +{ + memset(dro, 0, 64000); + memset(buf_addr, 0, 655360); + memset(buffer, 0, sizeof(unsigned short) * 300); + memset(a0b0_data2, 0, sizeof(unsigned short) * 11); + memset(a0b0_data3, 0, 18); + memset(a0b0_data4, 0, 18); + memset(a0b0_data5, 0, 96); + memset(addrs_head, 0, 96); + memset(insbuf, 0, 28 * sizeof(unsigned short)); + memset(displace, 0, 11 * sizeof(unsigned short)); + memset(reg_bufs, 0, 18 * sizeof(ADDT)); + memset(for40reg, 0, 18); + + if(opl->gettype() == Copl::TYPE_OPL2) + opl3_mode = 0; + else + opl3_mode = 1; +}; + bool CrixPlayer::load(const std::string &filename, const CFileProvider &fp) { - binistream *f = fp.open(filename); if(!f) return false; - unsigned long i=0; + binistream *f = fp.open(filename); if(!f) return false; + unsigned long i=0; - if(f->readInt(2)!=0x55aa) {fp.close(f);return false; } - buf_addr[i++]=0xaa;buf_addr[i++]=0x55; - while(!f->eof()) - buf_addr[i++]=f->readInt(1); - length=i; - fp.close(f); - set_new_int(); - data_initial(); - while(!dro_end) - int_08h_entry(); + if(f->readInt(2)!=0x55aa) {fp.close(f);return false; } + buf_addr[i++]=0xaa;buf_addr[i++]=0x55; + while(!f->eof()) + buf_addr[i++]=f->readInt(1); + length=i; + fp.close(f); + set_new_int(); + data_initial(); + while(!dro_end) + int_08h_entry(); - length=T; - mode = (OplMode)1; // Type of opl data this can contain + length=T; + mode = (OplMode)1; // Type of opl data this can contain -// binofstream *g=new binofstream(filename+string(".dro")); -// g->writeString("DBRAWOPL",8); -// g->writeInt(mstotal,4); -// g->writeInt(length+1,4); -// g->writeInt(1,1); -// for(int t=0;t<length;t++) -// g->writeInt(dro[t],1); -// g->close(); -// delete g; + // binofstream *g=new binofstream(filename+string(".dro")); + // g->writeString("DBRAWOPL",8); + // g->writeInt(mstotal,4); + // g->writeInt(length+1,4); + // g->writeInt(1,1); + // for(int t=0;t<length;t++) + // g->writeInt(dro[t],1); + // g->close(); + // delete g; - rewind(0); - return true; + rewind(0); + return true; } bool CrixPlayer::update() { - if (delay>500) { - delay-=500; - return true; - } else delay=1; - while (pos < length) - { - unsigned char cmd = dro[pos++]; - switch(cmd) { - case 0: - delay = 1 + dro[pos++]; - return true; - case 1: - delay = 1 + dro[pos] + (dro[pos+1]<<8); - pos+=2; - return true; - case 2: - index = 0; - opl->setchip(0); - break; - case 3: - index = 1; - opl->setchip(1); - break; - default: - if(index == 0 || opl3_mode) - opl->write(cmd,dro[pos++]); - break; - } - } - return pos<length; + if (delay>500) { + delay-=500; + return true; + } else delay=1; + while (pos < length) + { + unsigned char cmd = dro[pos++]; + switch(cmd) { + case 0: + delay = 1 + dro[pos++]; + return true; + case 1: + delay = 1 + dro[pos] + (dro[pos+1]<<8); + pos+=2; + return true; + case 2: + index = 0; + opl->setchip(0); + break; + case 3: + index = 1; + opl->setchip(1); + break; + default: + if(index == 0 || opl3_mode) + opl->write(cmd,dro[pos++]); + break; + } + } + return pos<length; } void CrixPlayer::rewind(int subsong) { - delay=1; - pos = index = 0; - opl->init(); - opl->write(1,32); // go to OPL2 mode + delay=1; + pos = index = 0; + opl->init(); + opl->write(1,32); // go to OPL2 mode } float CrixPlayer::getrefresh() { - if (delay > 500) return 1000 / 500; - else return 1000 / (double)delay; + if (delay > 500) return 1000 / 500; + else return 1000 / (double)delay; } /*------------------Implemention----------------------------*/ inline void CrixPlayer::set_new_int() { - if(!ad_initial()) exit(1); - prep_int(); + if(!ad_initial()) exit(1); + prep_int(); } /*----------------------------------------------------------*/ inline void CrixPlayer::Pause() { - register unsigned short i; - pause_flag = 1; - for(i=0;i<11;i++) - switch_ad_bd(i); + register unsigned short i; + pause_flag = 1; + for(i=0;i<11;i++) + switch_ad_bd(i); } /*----------------------------------------------------------*/ inline void CrixPlayer::ad_a0b0l_reg_(unsigned short index,unsigned short p2,unsigned short p3) { - unsigned short i = p2+a0b0_data2[index]; - a0b0_data4[index] = p3; - a0b0_data3[index] = p2; +// unsigned short i = p2+a0b0_data2[index]; + a0b0_data4[index] = p3; + a0b0_data3[index] = p2; } inline void CrixPlayer::data_initial() { - rhythm = buf_addr[2]; - mus_block = (buf_addr[0x0D]<<8)+buf_addr[0x0C]; - ins_block = (buf_addr[0x09]<<8)+buf_addr[0x08]; - I = mus_block+1; - if(rhythm != 0) - { -// ad_a0b0_reg(6); -// ad_a0b0_reg(7); -// ad_a0b0_reg(8); - ad_a0b0l_reg_(8,0x18,0); - ad_a0b0l_reg_(7,0x1F,0); - } - bd_modify = 0; -// ad_bd_reg(); - band = 0; music_on = 1; + rhythm = buf_addr[2]; + mus_block = (buf_addr[0x0D]<<8)+buf_addr[0x0C]; + ins_block = (buf_addr[0x09]<<8)+buf_addr[0x08]; + I = mus_block+1; + if(rhythm != 0) + { + // ad_a0b0_reg(6); + // ad_a0b0_reg(7); + // ad_a0b0_reg(8); + ad_a0b0l_reg_(8,0x18,0); + ad_a0b0l_reg_(7,0x1F,0); + } + bd_modify = 0; + // ad_bd_reg(); + band = 0; music_on = 1; } /*----------------------------------------------------------*/ inline unsigned short CrixPlayer::ad_initial() @@ -175,12 +201,12 @@ register unsigned short i,j,k = 0; for(i=0;i<25;i++) crc_trans(i,i*4); for(i=0;i<8;i++) - for(j=0;j<12;j++) - { - a0b0_data5[k] = i; - addrs_head[k] = j; - k++; - } + for(j=0;j<12;j++) + { + a0b0_data5[k] = i; + addrs_head[k] = j; + k++; + } //ad_bd_reg(); //ad_08_reg(); //for(i=0;i<9;i++) ad_a0b0_reg(i); @@ -192,318 +218,317 @@ /*----------------------------------------------------------*/ inline void CrixPlayer::crc_trans(unsigned short index,unsigned short v) { - register unsigned short i; - unsigned int res; unsigned short low; - res = strm_and_fr(v); - low = res; - buffer[index*12] = (low+4)>>3; - for(i=1;i<=11;i++) - { - res = (unsigned int)((double)res * 1.06); - buffer[index*12+i] = res>>3; - } + register unsigned short i; + unsigned int res; unsigned short low; + res = strm_and_fr(v); + low = res; + buffer[index*12] = (low+4)>>3; + for(i=1;i<=11;i++) + { + res = (unsigned int)((double)res * 1.06); + buffer[index*12+i] = res>>3; + } } /*----------------------------------------------------------*/ inline void CrixPlayer::prep_int() { - mutex = 0; + mutex = 0; } /*----------------------------------------------------------*/ inline void CrixPlayer::ad_bop(unsigned short reg,unsigned short value) { - dro[T++]=reg;dro[T++]=value; + dro[T++]=reg;dro[T++]=value; } /*------------------------------------------------------*/ inline unsigned short CrixPlayer::ad_test() /* Test the SoundCard */ { - ad_bop(0x04,0x60); - ad_bop(0x04,0x80); - ad_bop(0x02,0xFF); - ad_bop(0x04,0x21); - ad_bop(0x04,0x60); - ad_bop(0x04,0x80); - return 1; + ad_bop(0x04,0x60); + ad_bop(0x04,0x80); + ad_bop(0x02,0xFF); + ad_bop(0x04,0x21); + ad_bop(0x04,0x60); + ad_bop(0x04,0x80); + return 1; } /*--------------------------------------------------------------*/ inline void CrixPlayer::int_08h_entry() { - unsigned short band_sus = 1; - while(band_sus) - { - if(sustain <= 0 && mutex == 0) - { - mutex++; - band_sus = rix_proc(); - if(band_sus) sustain += (int)((double)band_sus * 1.06); - mstotal+=sustain; - dro[T++]=(sustain>=0x100?1:0); - dro[T++]=sustain&0xff; - if(sustain>=0x100) - dro[T++]=(sustain>>8)&0xff; - mutex--; - if(band_sus == 0) - { - dro_end=1; - break; - } - } - else - { - if(band_sus) sustain -= 14; /* aging */ - break; - } - } + unsigned short band_sus = 1; + while(band_sus) + { + if(sustain <= 0 && mutex == 0) + { + mutex++; + band_sus = rix_proc(); + if(band_sus) sustain += (int)((double)band_sus * 1.06); + mstotal+=sustain; + dro[T++]=(sustain>=0x100?1:0); + dro[T++]=sustain&0xff; + if(sustain>=0x100) + dro[T++]=(sustain>>8)&0xff; + mutex--; + if(band_sus == 0) + { + dro_end=1; + break; + } + } + else + { + if(band_sus) sustain -= 14; /* aging */ + break; + } + } } /*--------------------------------------------------------------*/ inline unsigned short CrixPlayer::rix_proc() { - unsigned char ctrl = 0; - if(music_on == 0||pause_flag == 1) return 0; - band = 0; - while(buf_addr[I] != 0x80 && I<length-1) + unsigned char ctrl = 0; + if(music_on == 0||pause_flag == 1) return 0; + band = 0; + while(buf_addr[I] != 0x80 && I<length-1) + { + band_low = buf_addr[I-1]; + ctrl = buf_addr[I]; I+=2; + switch(ctrl&0xF0) { - band_low = buf_addr[I-1]; - ctrl = buf_addr[I]; I+=2; - switch(ctrl&0xF0) - { - case 0x90: rix_get_ins(); rix_90_pro(ctrl&0x0F); break; - case 0xA0: rix_A0_pro(ctrl&0x0F,((unsigned short)band_low)<<6); break; - case 0xB0: rix_B0_pro(ctrl&0x0F,band_low); break; - case 0xC0: switch_ad_bd(ctrl&0x0F); - if(band_low != 0) rix_C0_pro(ctrl&0x0F,band_low); - break; - default: band = (ctrl<<8)+band_low; break; - } - if(band != 0) return band; + case 0x90: rix_get_ins(); rix_90_pro(ctrl&0x0F); break; + case 0xA0: rix_A0_pro(ctrl&0x0F,((unsigned short)band_low)<<6); break; + case 0xB0: rix_B0_pro(ctrl&0x0F,band_low); break; + case 0xC0: switch_ad_bd(ctrl&0x0F); + if(band_low != 0) rix_C0_pro(ctrl&0x0F,band_low); + break; + default: band = (ctrl<<8)+band_low; break; } - music_ctrl(); - I = mus_block+1; - band = 0; music_on = 1; - return 0; + if(band != 0) return band; + } + music_ctrl(); + I = mus_block+1; + band = 0; music_on = 1; + return 0; } /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_get_ins() { - memcpy(insbuf,(&buf_addr[ins_block])+(band_low<<6),56); + memcpy(insbuf,(&buf_addr[ins_block])+(band_low<<6),56); } /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_90_pro(unsigned short ctrl_l) { - if(rhythm == 0 || ctrl_l < 6) - { - ins_to_reg(modify[ctrl_l*2],insbuf,insbuf[26]); - ins_to_reg(modify[ctrl_l*2+1],insbuf+13,insbuf[27]); - return; - } - else + if(rhythm == 0 || ctrl_l < 6) + { + ins_to_reg(modify[ctrl_l*2],insbuf,insbuf[26]); + ins_to_reg(modify[ctrl_l*2+1],insbuf+13,insbuf[27]); + return; + } + else + { + if(ctrl_l > 6) { - if(ctrl_l > 6) - { - ins_to_reg(modify[ctrl_l*2+6],insbuf,insbuf[26]); - return; - } - else - { - ins_to_reg(12,insbuf,insbuf[26]); - ins_to_reg(15,insbuf+13,insbuf[27]); - return; - } + ins_to_reg(modify[ctrl_l*2+6],insbuf,insbuf[26]); + return; } + else + { + ins_to_reg(12,insbuf,insbuf[26]); + ins_to_reg(15,insbuf+13,insbuf[27]); + return; + } + } } /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_A0_pro(unsigned short ctrl_l,unsigned short index) { - if(rhythm == 0 || ctrl_l <= 6) - { - prepare_a0b0(ctrl_l,index>0x3FFF?0x3FFF:index); - ad_a0b0l_reg(ctrl_l,a0b0_data3[ctrl_l],a0b0_data4[ctrl_l]); - } - else return; + if(rhythm == 0 || ctrl_l <= 6) + { + prepare_a0b0(ctrl_l,index>0x3FFF?0x3FFF:index); + ad_a0b0l_reg(ctrl_l,a0b0_data3[ctrl_l],a0b0_data4[ctrl_l]); + } + else return; } /*--------------------------------------------------------------*/ inline void CrixPlayer::prepare_a0b0(unsigned short index,unsigned short v) /* important !*/ { - short high = 0,low = 0; unsigned int res; - low = ((unsigned short)(v-0x2000))*0x19; - high = ((short)v)<0x2000?0xFFFF:0; - if(low == 0xFF && high == 0) return; - res = ((((unsigned int)high)<<16)|low)/0x2000; - low = res&0xFFFF; - if(low < 0) - { - low = 0x18-low; high = (signed short)low<0?0xFFFF:0; - res = high; res<<=16; res+=low; - low = ((signed short)res)/(signed short)0xFFE7; - a0b0_data2[index] = low; - low = res; - res = low - 0x18; - high = (signed short)res%0x19; - low = (signed short)res/0x19; - if(high != 0) {low = 0x19; low = low-high;} - } - else - { - res = high = low; - low = (signed short)res/(signed short)0x19; - a0b0_data2[index] = low; - res = high; - low = (signed short)res%(signed short)0x19; - } - low = (signed short)low*(signed short)0x18; - displace[index] = low; + short high = 0,low = 0; unsigned int res; + low = ((unsigned short)(v-0x2000))*0x19; + high = ((short)v)<0x2000?0xFFFF:0; + if(low == 0xFF && high == 0) return; + res = ((((unsigned int)high)<<16)|low)/0x2000; + low = res&0xFFFF; + if(low < 0) + { + low = 0x18-low; high = (signed short)low<0?0xFFFF:0; + res = high; res<<=16; res+=low; + low = ((signed short)res)/(signed short)0xFFE7; + a0b0_data2[index] = low; + low = res; + res = low - 0x18; + high = (signed short)res%0x19; + low = (signed short)res/0x19; + if(high != 0) {low = 0x19; low = low-high;} + } + else + { + res = high = low; + low = (signed short)res/(signed short)0x19; + a0b0_data2[index] = low; + res = high; + low = (signed short)res%(signed short)0x19; + } + low = (signed short)low*(signed short)0x18; + displace[index] = low; } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_a0b0l_reg(unsigned short index,unsigned short p2,unsigned short p3) { - unsigned short data; unsigned short i = p2+a0b0_data2[index]; - a0b0_data4[index] = p3; - a0b0_data3[index] = p2; - i = ((signed short)i<=0x5F?i:0x5F); - i = ((signed short)i>=0?i:0); - data = buffer[addrs_head[i]+displace[index]/2]; - ad_bop(0xA0+index,data); - data = a0b0_data5[i]*4+(p3<1?0:0x20)+((data>>8)&3); - ad_bop(0xB0+index,data); + unsigned short data; unsigned short i = p2+a0b0_data2[index]; + a0b0_data4[index] = p3; + a0b0_data3[index] = p2; + i = ((signed short)i<=0x5F?i:0x5F); + i = ((signed short)i>=0?i:0); + data = buffer[addrs_head[i]+displace[index]/2]; + ad_bop(0xA0+index,data); + data = a0b0_data5[i]*4+(p3<1?0:0x20)+((data>>8)&3); + ad_bop(0xB0+index,data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_B0_pro(unsigned short ctrl_l,unsigned short index) { - register int temp = 0; - if(rhythm == 0 || ctrl_l < 6) temp = modify[ctrl_l*2+1]; - else - { - temp = ctrl_l > 6?ctrl_l*2:ctrl_l*2+1; - temp = modify[temp+6]; - } - for40reg[temp] = index>0x7F?0x7F:index; - ad_40_reg(temp); + register int temp = 0; + if(rhythm == 0 || ctrl_l < 6) temp = modify[ctrl_l*2+1]; + else + { + temp = ctrl_l > 6?ctrl_l*2:ctrl_l*2+1; + temp = modify[temp+6]; + } + for40reg[temp] = index>0x7F?0x7F:index; + ad_40_reg(temp); } /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_C0_pro(unsigned short ctrl_l,unsigned short index) { - register unsigned short i = index>=12?index-12:0; - if(ctrl_l < 6 || rhythm == 0) - { - ad_a0b0l_reg(ctrl_l,i,1); - return; - } - else + register unsigned short i = index>=12?index-12:0; + if(ctrl_l < 6 || rhythm == 0) + { + ad_a0b0l_reg(ctrl_l,i,1); + return; + } + else + { + if(ctrl_l != 6) { - if(ctrl_l != 6) - { - if(ctrl_l == 8) - { - ad_a0b0l_reg(ctrl_l,i,0); - ad_a0b0l_reg(7,i+7,0); - } - } - else ad_a0b0l_reg(ctrl_l,i,0); - bd_modify |= bd_reg_data[ctrl_l]; - ad_bd_reg(); - return; + if(ctrl_l == 8) + { + ad_a0b0l_reg(ctrl_l,i,0); + ad_a0b0l_reg(7,i+7,0); + } } + else ad_a0b0l_reg(ctrl_l,i,0); + bd_modify |= bd_reg_data[ctrl_l]; + ad_bd_reg(); + return; + } } /*--------------------------------------------------------------*/ inline void CrixPlayer::switch_ad_bd(unsigned short index) { - if(rhythm == 0 || index < 6) ad_a0b0l_reg(index,a0b0_data3[index],0); - else - { - bd_modify &= (~bd_reg_data[index]), - ad_bd_reg(); - } + if(rhythm == 0 || index < 6) ad_a0b0l_reg(index,a0b0_data3[index],0); + else + { + bd_modify &= (~bd_reg_data[index]), + ad_bd_reg(); + } } /*--------------------------------------------------------------*/ inline void CrixPlayer::ins_to_reg(unsigned short index,unsigned short* insb,unsigned short value) { - register unsigned short i; - for(i=0;i<13;i++) reg_bufs[index].v[i] = insb[i]; - reg_bufs[index].v[13] = value&3; - ad_bd_reg(),ad_08_reg(), - ad_40_reg(index),ad_C0_reg(index),ad_60_reg(index), - ad_80_reg(index),ad_20_reg(index),ad_E0_reg(index); + register unsigned short i; + for(i=0;i<13;i++) reg_bufs[index].v[i] = insb[i]; + reg_bufs[index].v[13] = value&3; + ad_bd_reg(),ad_08_reg(), + ad_40_reg(index),ad_C0_reg(index),ad_60_reg(index), + ad_80_reg(index),ad_20_reg(index),ad_E0_reg(index); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_E0_reg(unsigned short index) { - unsigned short data = e0_reg_flag == 0?0:(reg_bufs[index].v[13]&3); - ad_bop(0xE0+reg_data[index],data); + unsigned short data = e0_reg_flag == 0?0:(reg_bufs[index].v[13]&3); + ad_bop(0xE0+reg_data[index],data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_20_reg(unsigned short index) { - unsigned short data = (reg_bufs[index].v[9] < 1?0:0x80); - data += (reg_bufs[index].v[10] < 1?0:0x40); - data += (reg_bufs[index].v[5] < 1?0:0x20); - data += (reg_bufs[index].v[11] < 1?0:0x10); - data += (reg_bufs[index].v[1]&0x0F); - ad_bop(0x20+reg_data[index],data); + unsigned short data = (reg_bufs[index].v[9] < 1?0:0x80); + data += (reg_bufs[index].v[10] < 1?0:0x40); + data += (reg_bufs[index].v[5] < 1?0:0x20); + data += (reg_bufs[index].v[11] < 1?0:0x10); + data += (reg_bufs[index].v[1]&0x0F); + ad_bop(0x20+reg_data[index],data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_80_reg(unsigned short index) { - unsigned short data = (reg_bufs[index].v[7]&0x0F),temp = reg_bufs[index].v[4]; - data |= (temp << 4); - ad_bop(0x80+reg_data[index],data); + unsigned short data = (reg_bufs[index].v[7]&0x0F),temp = reg_bufs[index].v[4]; + data |= (temp << 4); + ad_bop(0x80+reg_data[index],data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_60_reg(unsigned short index) { - unsigned short data = reg_bufs[index].v[6]&0x0F,temp = reg_bufs[index].v[3]; - data |= (temp << 4); - ad_bop(0x60+reg_data[index],data); + unsigned short data = reg_bufs[index].v[6]&0x0F,temp = reg_bufs[index].v[3]; + data |= (temp << 4); + ad_bop(0x60+reg_data[index],data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_C0_reg(unsigned short index) { - unsigned short data = reg_bufs[index].v[2]; - if(adflag[index] == 1) return; - data *= 2, - data |= (reg_bufs[index].v[12] < 1?1:0); - ad_bop(0xC0+ad_C0_offs[index],data); + unsigned short data = reg_bufs[index].v[2]; + if(adflag[index] == 1) return; + data *= 2, + data |= (reg_bufs[index].v[12] < 1?1:0); + ad_bop(0xC0+ad_C0_offs[index],data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_40_reg(unsigned short index) { - unsigned int res = 0; - unsigned short data = 0,temp = reg_bufs[index].v[0]; - data = 0x3F - (0x3F & reg_bufs[index].v[8]), - data *= for40reg[index], - data *= 2, - data += 0x7F, - res = data; - data = res/0xFE, - data -= 0x3F, - data = -data, - data |= temp<<6; - ad_bop(0x40+reg_data[index],data); + unsigned int res = 0; + unsigned short data = 0,temp = reg_bufs[index].v[0]; + data = 0x3F - (0x3F & reg_bufs[index].v[8]), + data *= for40reg[index], + data *= 2, + data += 0x7F, + res = data; + data = res/0xFE, + data -= 0x3F, + data = -data, + data |= temp<<6; + ad_bop(0x40+reg_data[index],data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_bd_reg() { - unsigned short data = rhythm < 1? 0:0x20; - data |= bd_modify; - ad_bop(0xBD,data); + unsigned short data = rhythm < 1? 0:0x20; + data |= bd_modify; + ad_bop(0xBD,data); } /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_a0b0_reg(unsigned short index) { - ad_bop(0xA0+index,0); - ad_bop(0xB0+index,0); + ad_bop(0xA0+index,0); + ad_bop(0xB0+index,0); } /*--------------------------------------------------------------*/ inline void CrixPlayer::music_ctrl() { - register int i; - music_on = 0; - for(i=0;i<11;i++) - switch_ad_bd(i); + register int i; + music_on = 0; + for(i=0;i<11;i++) + switch_ad_bd(i); } /*----------------------------------------------------------------------*/ inline unsigned int CrixPlayer::strm_and_fr(unsigned short parm) { - return (int)(((unsigned int)parm*6+10000)*0.27461678223); + return (int)(((unsigned int)parm*6+10000)*0.27461678223); } -
--- a/Plugins/Input/adplug/core/rix.h Thu Feb 16 07:40:35 2006 -0800 +++ b/Plugins/Input/adplug/core/rix.h Sat Feb 18 08:23:30 2006 -0800 @@ -1,6 +1,6 @@ /* * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al. + * Copyright (C) 1999 - 2006 Simon Peter, <dn.tlp@gmx.net>, et al. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,108 +23,97 @@ class CrixPlayer: public CPlayer { -public: + public: static CPlayer *factory(Copl *newopl); - CrixPlayer(Copl *newopl) - : CPlayer(newopl),I(0),T(0),mus_block(0),ins_block(0),rhythm(0),mutex(0),music_on(0), - pause_flag(0),band(0),band_low(0),e0_reg_flag(0),bd_modify(0),sustain(0),dro_end(0) - { - // memset(buffer,0,97948); - int i=0,j=i*3; - unsigned long t=9; + CrixPlayer(Copl *newopl); + ~CrixPlayer() {}; + + bool load(const std::string &filename, const CFileProvider &fp); + bool update(); + void rewind(int subsong); + float getrefresh(); - if(opl->gettype() == Copl::TYPE_OPL2) - opl3_mode = 0; - else - opl3_mode = 1; - }; - ~CrixPlayer() - {}; + std::string gettype() + { return std::string("Softstar RIX OPL Music Format"); }; - bool load(const std::string &filename, const CFileProvider &fp); - bool update(); - void rewind(int subsong); - float getrefresh(); + protected: + typedef struct { + unsigned char v[14]; + } ADDT; - std::string gettype() - { return std::string("Softstar RIX OPL Music Format"); }; - - typedef struct {unsigned char v[14];}ADDT; - -protected: - unsigned char dro[64000]; - unsigned char buf_addr[655360]; /* rix files' buffer */ - unsigned short buffer[300]; - unsigned short a0b0_data2[11]; - unsigned char a0b0_data3[18]; - unsigned char a0b0_data4[18]; - unsigned char a0b0_data5[96]; - unsigned char addrs_head[96]; - unsigned short insbuf[28]; - unsigned short displace[11]; - ADDT reg_bufs[18]; - unsigned long pos,length; - unsigned long msdone,mstotal; - unsigned short delay; - unsigned char index, opl3_mode; - enum OplMode { - ModeOPL2,ModeOPL3,ModeDUALOPL2 - } mode; + unsigned char dro[64000]; + unsigned char buf_addr[655360]; /* rix files' buffer */ + unsigned short buffer[300]; + unsigned short a0b0_data2[11]; + unsigned char a0b0_data3[18]; + unsigned char a0b0_data4[18]; + unsigned char a0b0_data5[96]; + unsigned char addrs_head[96]; + unsigned short insbuf[28]; + unsigned short displace[11]; + ADDT reg_bufs[18]; + unsigned long pos,length; + unsigned long msdone,mstotal; + unsigned short delay; + unsigned char index, opl3_mode; + enum OplMode { + ModeOPL2,ModeOPL3,ModeDUALOPL2 + } mode; - static const unsigned char adflag[18]; - static const unsigned char reg_data[18]; - static const unsigned char ad_C0_offs[18]; - static const unsigned char modify[28]; - static const unsigned char bd_reg_data[124]; - static unsigned char for40reg[18]; - static unsigned short mus_time; - unsigned int I,T; - unsigned short mus_block; - unsigned short ins_block; - unsigned char rhythm; - unsigned char mutex; - unsigned char music_on; - unsigned char pause_flag; - unsigned short band; - unsigned char band_low; - unsigned short e0_reg_flag; - unsigned char bd_modify; - int sustain; - int dro_end; + static const unsigned char adflag[18]; + static const unsigned char reg_data[18]; + static const unsigned char ad_C0_offs[18]; + static const unsigned char modify[28]; + static const unsigned char bd_reg_data[124]; + static unsigned char for40reg[18]; + static unsigned short mus_time; + unsigned int I,T; + unsigned short mus_block; + unsigned short ins_block; + unsigned char rhythm; + unsigned char mutex; + unsigned char music_on; + unsigned char pause_flag; + unsigned short band; + unsigned char band_low; + unsigned short e0_reg_flag; + unsigned char bd_modify; + int sustain; + int dro_end; - #define ad_08_reg() ad_bop(8,0) /**/ - inline void ad_20_reg(unsigned short); /**/ - inline void ad_40_reg(unsigned short); /**/ - inline void ad_60_reg(unsigned short); /**/ - inline void ad_80_reg(unsigned short); /**/ - inline void ad_a0b0_reg(unsigned short); /**/ - inline void ad_a0b0l_reg(unsigned short,unsigned short,unsigned short); /**/ - inline void ad_a0b0l_reg_(unsigned short,unsigned short,unsigned short); /**/ - inline void ad_bd_reg(); /**/ - inline void ad_bop(unsigned short,unsigned short); /**/ - inline void ad_C0_reg(unsigned short); /**/ - inline void ad_E0_reg(unsigned short); /**/ - inline unsigned short ad_initial(); /**/ - inline unsigned short ad_test(); /**/ - inline void crc_trans(unsigned short,unsigned short); /**/ - inline void data_initial(); /* done */ - inline void init(); /**/ - inline void ins_to_reg(unsigned short,unsigned short*,unsigned short); /**/ - inline void int_08h_entry(); /**/ - inline void music_ctrl(); /**/ - inline void Pause(); /**/ - inline void prep_int(); /**/ - inline void prepare_a0b0(unsigned short,unsigned short); /**/ - inline void rix_90_pro(unsigned short); /**/ - inline void rix_A0_pro(unsigned short,unsigned short); /**/ - inline void rix_B0_pro(unsigned short,unsigned short); /**/ - inline void rix_C0_pro(unsigned short,unsigned short); /**/ - inline void rix_get_ins(); /**/ - inline unsigned short rix_proc(); /**/ - inline void set_new_int(); - inline void set_speed(unsigned short); /**/ - inline void set_time(unsigned short); /**/ - inline void switch_ad_bd(unsigned short); /**/ - inline unsigned int strm_and_fr(unsigned short); /* done */ +#define ad_08_reg() ad_bop(8,0) /**/ + inline void ad_20_reg(unsigned short); /**/ + inline void ad_40_reg(unsigned short); /**/ + inline void ad_60_reg(unsigned short); /**/ + inline void ad_80_reg(unsigned short); /**/ + inline void ad_a0b0_reg(unsigned short); /**/ + inline void ad_a0b0l_reg(unsigned short,unsigned short,unsigned short); /**/ + inline void ad_a0b0l_reg_(unsigned short,unsigned short,unsigned short); /**/ + inline void ad_bd_reg(); /**/ + inline void ad_bop(unsigned short,unsigned short); /**/ + inline void ad_C0_reg(unsigned short); /**/ + inline void ad_E0_reg(unsigned short); /**/ + inline unsigned short ad_initial(); /**/ + inline unsigned short ad_test(); /**/ + inline void crc_trans(unsigned short,unsigned short); /**/ + inline void data_initial(); /* done */ + inline void init(); /**/ + inline void ins_to_reg(unsigned short,unsigned short*,unsigned short); /**/ + inline void int_08h_entry(); /**/ + inline void music_ctrl(); /**/ + inline void Pause(); /**/ + inline void prep_int(); /**/ + inline void prepare_a0b0(unsigned short,unsigned short); /**/ + inline void rix_90_pro(unsigned short); /**/ + inline void rix_A0_pro(unsigned short,unsigned short); /**/ + inline void rix_B0_pro(unsigned short,unsigned short); /**/ + inline void rix_C0_pro(unsigned short,unsigned short); /**/ + inline void rix_get_ins(); /**/ + inline unsigned short rix_proc(); /**/ + inline void set_new_int(); + inline void set_speed(unsigned short); /**/ + inline void set_time(unsigned short); /**/ + inline void switch_ad_bd(unsigned short); /**/ + inline unsigned int strm_and_fr(unsigned short); /* done */ };