00001
00002
00003
00004
00005 #include "mus_.h"
00006
00007
00008 const char text_format[] = "C64 Stereo-/Sidplayer format (MUS)";
00009 const uword HLTcmd = 0x14F;
00010
00011
00012 bool sidTune::MUS_fileSupport( void* musBuffer, udword musLength )
00013 {
00014
00015 info.formatString = 0;
00016
00017 smartPtr<ubyte> spMus((ubyte*)musBuffer,musLength);
00018
00019 udword voice1Index = (2+3*2);
00020
00021 voice1Index += readEndian(spMus[3],spMus[2]);
00022
00023 udword voice2Index = voice1Index + readEndian(spMus[5],spMus[4]);
00024
00025 udword voice3Index = voice2Index + readEndian(spMus[7],spMus[6]);
00026 if ( (readEndian(spMus[voice1Index-2],spMus[voice1Index+1-2]) != HLTcmd)
00027 || (readEndian(spMus[voice2Index-2],spMus[voice2Index+1-2]) != HLTcmd)
00028 || (readEndian(spMus[voice3Index-2],spMus[voice3Index+1-2]) != HLTcmd)
00029 || !spMus )
00030 {
00031 return false;
00032 }
00033
00034 infoString[0][0] = 0;
00035 infoString[1][0] = 0;
00036 infoString[2][0] = 0;
00037 infoString[3][0] = 0;
00038 infoString[4][0] = 0;
00039
00040
00041 smartPtr<char> spPet((char*)musBuffer,musLength);
00042 spPet += voice3Index;
00043 for ( int line = 0; line < 5; line++ )
00044 {
00045 char c;
00046 char si = 0;
00047 do
00048 {
00049 c = *spPet;
00050 spPet++;
00051
00052 if (( c >= 0x20 ) && ( c < 96 ) && ( si < 31 ))
00053 {
00054 infoString[line][si] = c;
00055 si++;
00056 }
00057 }
00058 while ( !((c == 0x0D) || (c == 0x00) || spPet.fail()) );
00059 info.infoString[line] = &infoString[line][0];
00060 }
00061 info.numberOfInfoStrings = 5;
00062
00063 info.loadAddr = 0x1000;
00064 info.initAddr = 0xc7b0;
00065 info.playAddr = 0;
00066 info.songs = (info.startSong = 1);
00067 info.musPlayer = true;
00068 fileOffset = 2;
00069 songSpeed[0] = SIDTUNE_SPEED_CIA_1A;
00070 info.formatString = text_format;
00071 return true;
00072 }
00073
00074
00075 static const ubyte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0x10, 0x5,0x18,0x69, 0xc,0xe6,0xfd,0xc9, 0xc,0x90, 0x4,0xe9, 0xc,0xc6,
00130 0xfd,0x85,0xfe,0xa8,0xa5,0xff,0x48,0xb9,0xf2,0xc0,0x85,0xff,0xb9,0xe6,0xc0,0xa4,
00131 0xfd,0x88,0x30, 0x6,0x46,0xff,0x6a,0x88,0x10,0xfa,0x18,0x7d,0x4e,0xc0,0x9d,0x54,
00132 0xc0,0xa5,0xff,0x7d,0x51,0xc0,0x9d,0x57,0xc0,0x68,0x85,0xff,0x29,0x1c,0xf0,0xb6,
00133 0xbd,0x2d,0xc0,0x1d,0x30,0xc0,0xf0,0x16,0xbd, 0x5,0xc0,0xdd,0x54,0xc0,0xbd, 0x8,
00134 0xc0,0xfd,0x57,0xc0,0xa9,0xfe,0x6a,0x9d,0x2a,0xc0,0x90,0x11,0xf0,0x57,0x9d,0x2a,
00135 0xc0,0xbd,0x54,0xc0,0x9d, 0x5,0xc0,0xbd,0x57,0xc0,0x9d, 0x8,0xc0,0xbd,0x24,0xc0,
00136 0xa,0xd0,0x42,0xbd,0x5a,0xc0,0xf0,0x13,0xbd,0x60,0xc0,0x9d, 0xb,0xc0,0xa0, 0x2,
00137 0x91,0xfb,0xbd,0x63,0xc0,0x9d, 0xe,0xc0,0xc8,0x91,0xfb,0xbd,0x66,0xc0,0xf0, 0xf,
00138 0xa4,0xfd,0x18,0x79,0xfe,0xc0,0xa4,0xfe,0x18,0x79, 0x6,0xc1,0x18,0x90, 0x8,0xbd,
00139 0x69,0xc0,0xf0,0x11,0xbd,0x6c,0xc0,0x8d,0x1b,0xc0,0x8d,0x16,0xd4,0xa9, 0x0,0x8d,
00140 0x1a,0xc0,0x8d,0x15,0xd4,0xa5,0xff,0xa8,0x29,0x20,0x85,0xff,0x98,0x29,0x40,0x9d,
00141 0x24,0xc0,0x98,0x29,0x1c,0x4a,0x4a,0xa8,0xad,0x1f,0xc0,0x88,0xf0,0x1c,0xad,0x1e,
00142 0xc0,0xd0, 0x1,0x38,0x88,0xf0, 0x6,0x6a,0xb0,0x39,0x88,0xd0,0xfa,0xa4,0xff,0x85,
00143 0xff,0xf0, 0x7,0x4a,0xb0,0x2d,0x65,0xff,0xb0,0x2c,0x9d,0x21,0xc0,0xbd,0x6f,0xc0,
00144 0xa, 0xa,0x1d,0x72,0xc0, 0xa,0x1d,0x75,0xc0, 0xa,0x9d,0x11,0xc0,0x38,0xbd, 0x2,
00145 0xc0,0x29, 0x7,0xd0, 0x3,0x7e,0x24,0xc0,0xbd,0x11,0xc0,0x69, 0x0,0x9d,0x78,0xc0,
00146 0x6c,0xd1,0xc0,0xa9,0x10,0x2c,0xa9,0x18,0x8d, 0x0,0xc0,0x60,0x98,0x48,0xa5,0xff,
00147 0x4a,0xb0,0x71,0x4a,0x4a,0xb0,0x1f,0x4a,0xb0, 0xf,0x9d,0x63,0xc0,0xa0, 0x3,0x91,
00148 0xfb,0x68,0x9d,0x60,0xc0,0x88,0x91,0xfb,0x60,0x4a,0x90, 0x2, 0x9,0xf8,0x9d,0x51,
00149 0xc0,0x68,0x9d,0x4e,0xc0,0x60,0x4a,0x90, 0xb,0x4a,0x68,0xb0, 0x6,0x9d,0x6c,0xc0,
00150 0x8d,0x16,0xd4,0x60,0xa8,0xf0,0x22,0x68,0x88,0xf0,0x23,0x88,0xf0,0x24,0x88,0xf0,
00151 0x25,0x88,0xf0,0x32,0x88,0xf0,0x33,0x88,0xf0,0x3c,0x88,0xf0,0x3d,0x88,0xf0,0x59,
00152 0x88,0xf0,0x5a,0x88,0xf0,0x5b,0x6c,0xd3,0xc0,0x68,0x8d,0x1e,0xc0,0x60,0x8d,0x1f,
00153 0xc0,0x60,0x9d,0x27,0xc0,0x60,0x9d,0x87,0xc0,0xa5,0xfd,0x9d,0x81,0xc0,0xa5,0xfe,
00154 0x9d,0x84,0xc0,0x60,0xb0,0x55,0x8d, 0x1,0xc0,0x60,0x9d,0x5a,0xc0, 0xa,0x90, 0x1,
00155 0x88,0x98,0x9d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0xdd,0x14,0xc1,0xf0,0x12,0xde,0x8a,0xc0,0xa8,0x88,0xb9,0x99,0xc0,0xf0, 0x7,
00182 0x85,0xfe,0xb9,0x8d,0xc0,0x85,0xfd,0x60,0xa9,0x20,0x8d, 0x0,0xc0,0x60,0xad, 0x0,
00183 0xc0,0x5d,0xd6,0xc0,0x8d, 0x0,0xc0,0x88,0x98,0x91,0xfb,0xc8,0x91,0xfb,0x60,0x8e,
00184 0xcb,0xc0,0x8c,0xcc,0xc0,0x8a,0x18,0x69,0x6a,0x8d,0xc6,0xc0,0x98,0x69, 0x0,0x8d,
00185 0xc7,0xc0,0x8a,0x18,0x69,0x23,0x8d,0xc9,0xc0,0x98,0x69, 0x3,0x8d,0xca,0xc0,0x86,
00186 0xfb,0x84,0xfc,0xa9,0xec,0x85,0xfd,0xa9,0xc1,0x85,0xfe,0xa2, 0x5,0xa0, 0x0,0xb1,
00187 0xfd,0x91,0xfb,0xc8,0xd0,0xf9,0xe6,0xfc,0xe6,0xfe,0xca,0xd0,0xf2,0xb1,0xfd,0x91,
00188 0xfb,0xc8,0xc0,0x76,0xd0,0xf7,0x60,0x82,0x80,0x80,0x80,0x82, 0x0,0x20,0xdd,0xc1,
00189 0x20,0x1b,0xc1,0xa2, 0x0,0xa0,0x10,0x20,0x32,0xc1,0xa9, 0x7,0x8d, 0x0,0xc0,0x60
00190 };
00191
00192
00193 void sidTune::MUS_installPlayer(ubyte *c64buf)
00194 {
00195 if (status && (c64buf != 0))
00196 {
00197 uword dest = readEndian(sidplayer[1],sidplayer[0]);
00198 for ( uword i = 2; i < sizeof(sidplayer); i++ )
00199 {
00200 c64buf[dest+i-2] = sidplayer[i];
00201 }
00202 }
00203 }