MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / loadFile

Method loadFile

extlibs/soloud/src/audiosource/monotone/soloud_monotone.cpp:421–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419 }
420
421 result Monotone::loadFile(File *aFile)
422 {
423 if (aFile == NULL)
424 return INVALID_PARAMETER;
425 clear();
426 int i;
427 unsigned char temp[200];
428 aFile->read(temp, 9);
429 char magic[] = "\bMONOTONE";
430 for (i = 0; i < 9; i++)
431 {
432 if (temp[i] != magic[i])
433 {
434 return FILE_LOAD_FAILED;
435 }
436 }
437 aFile->read(temp, 41);
438 temp[temp[0] + 1] = 0; // pascal -> asciiz: pascal strings have length as first byte
439 mSong.mTitle = mystrdup((char*)temp + 1);
440 aFile->read(temp, 41);
441 temp[temp[0] + 1] = 0; // pascal -> asciiz: pascal strings have length as first byte
442 mSong.mComment = mystrdup((char*)temp + 1);
443 aFile->read(temp, 4);
444 mSong.mVersion = temp[0];
445 mSong.mTotalPatterns = temp[1];
446 mSong.mTotalTracks = temp[2];
447 mSong.mCellSize = temp[3];
448 if (mSong.mVersion != 1 || mSong.mCellSize != 2)
449 {
450 return FILE_LOAD_FAILED;
451 }
452 aFile->read(mSong.mOrder, 256);
453 int totalnotes = 64 * mSong.mTotalPatterns * mSong.mTotalTracks;
454 mSong.mPatternData = new unsigned int[totalnotes];
455 for (i = 0; i < totalnotes; i++)
456 {
457 aFile->read(temp, 2);
458 unsigned int datavalue = temp[0] | (temp[1] << 8);
459 mSong.mPatternData[i] = datavalue;
460 //unsigned int note = (datavalue >> 9) & 127;
461 //unsigned int effect = (datavalue >> 6) & 7;
462 //unsigned int effectdata = (datavalue)& 63;
463 //unsigned int effectdata1 = (datavalue >> 3) & 7;
464 //unsigned int effectdata2 = (datavalue >> 0) & 7;
465 }
466
467 return SO_NO_ERROR;
468 }
469
470
471 AudioSourceInstance * Monotone::createInstance()

Callers

nothing calls this directly

Calls 3

clearFunction · 0.85
mystrdupFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected