/* * Adplug - Replayer for many OPL2/OPL3 audio file formats. * Copyright (C) 1999 - 2003 Simon Peter, , 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 * * [xad] RAT player, by Riven the Mage */ /* - discovery - file(s) : PINA.EXE type : Experimental Connection BBStro tune tune : by (?)Ratt/GRIF player : by (?)Ratt/GRIF comment : there are bug in original replayer's adlib_init(): wrong frequency registers. */ #include #include "rat.h" #include "debug.h" const unsigned char CxadratPlayer::rat_adlib_bases[18] = { 0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12, 0x03, 0x04, 0x05, 0x0B, 0x0C, 0x0D, 0x13, 0x14, 0x15 }; const unsigned short CxadratPlayer::rat_notes[16] = { 0x157, 0x16B, 0x181, 0x198, 0x1B0, 0x1CA, 0x1E5, 0x202, 0x220, 0x241, 0x263, 0x287, 0x000, 0x000, 0x000, 0x000 // by riven }; CPlayer *CxadratPlayer::factory(Copl *newopl) { return new CxadratPlayer(newopl); } bool CxadratPlayer::xadplayer_load() { if(xad.fmt != RAT) return false; // load header memcpy(&rat.hdr, &tune[0], sizeof(rat_header)); // is 'RAT'-signed ? if (strncmp(rat.hdr.id,"RAT",3)) return false; // is version 1.0 ? if (rat.hdr.version != 0x10) return false; // load order rat.order = &tune[0x40]; // load instruments rat.inst = (rat_instrument *)&tune[0x140]; // load pattern data unsigned short patseg = (rat.hdr.patseg[1] << 8) + rat.hdr.patseg[0]; unsigned char *event_ptr = &tune[patseg << 4]; for(int i=0;i> 8) | ((event.note & 0xF0) >> 2) | 0x20); } } // is effect ? if (event.fx != 0xFF) { rat.channel[i].fx = event.fx; rat.channel[i].fxp = event.fxp; } } // next row rat.pattern_pos++; // process effects for(i=0;i= 0x40) { rat.pattern_pos = 0; rat.order_pos++; // end of module ? if (rat.order_pos == rat.hdr.order_end) { rat.order_pos = rat.hdr.order_loop; plr.looping = 1; } } } float CxadratPlayer::xadplayer_getrefresh() { return 60.0f; } const char * CxadratPlayer::xadplayer_gettype() { return "xad: rat player"; } const char * CxadratPlayer::xadplayer_gettitle() { return rat.hdr.title; } unsigned int CxadratPlayer::xadplayer_getinstruments() { return rat.hdr.numinst; } /* -------- Internal Functions ---------------------------- */ unsigned char CxadratPlayer::__rat_calc_volume(unsigned char ivol, unsigned char cvol, unsigned char gvol) { #ifdef DEBUG AdPlug_LogWrite("volumes: instrument %02X, channel %02X, global %02X:\n", ivol, cvol, gvol); #endif unsigned short vol; vol = ivol; vol &= 0x3F; vol ^= 0x3F; vol *= cvol; vol >>= 6; vol *= gvol; vol >>= 6; vol ^= 0x3F; vol |= ivol & 0xC0; return vol; }