Ticket #9070: tfmx.patch

File tfmx.patch, 2.0 KB (added by SF/nolange, 15 years ago)

Example using the CONSTANT_* macro

  • sound/mods/tfmx.cpp

     
    619619        for (;;) {
    620620                const uint16 *const trackData = getTrackPtr(_trackCtx.posInd);
    621621
    622                 if (trackData[0] != FROM_BE_16(0xEFFE)) {
     622                if (trackData[0] != CONSTANT_BE_16(0xEFFE)) {
    623623                        // 8 commands for Patterns
    624624                        for (int i = 0; i < 8; ++i) {
    625625                                const uint8 *patCmd = (const uint8 *)&trackData[i];
     
    637637
    638638                } else {
    639639                        // 16 byte Trackstep Command
    640                         switch (READ_BE_UINT16(&trackData[1])) {
    641                         case 0: // Stop Player. No Parameters
     640                        switch (trackData[1]) {
     641                        case CONSTANT_BE_16(0): // Stop Player. No Parameters
    642642                                stopPaula();
    643643                                return false;
    644644
    645                         case 1: // Branch/Loop section of tracksteps. Parameters: branch target, loopcount
     645                        case CONSTANT_BE_16(1): // Branch/Loop section of tracksteps. Parameters: branch target, loopcount
    646646                                if (_trackCtx.loopCount != 0) {
    647647                                        if (_trackCtx.loopCount < 0)
    648648                                                _trackCtx.loopCount = READ_BE_UINT16(&trackData[3]);
     
    652652                                --_trackCtx.loopCount;
    653653                                break;
    654654
    655                         case 2: { // Set Tempo. Parameters: tempo, divisor
     655                        case CONSTANT_BE_16(2): { // Set Tempo. Parameters: tempo, divisor
    656656                                _playerCtx.patternCount = _playerCtx.patternSkip = READ_BE_UINT16(&trackData[2]); // tempo
    657657                                const uint16 temp = READ_BE_UINT16(&trackData[3]); // divisor
    658658
     
    660660                                        setInterruptFreqUnscaled(temp & 0x1FF);
    661661                                break;
    662662                        }
    663                         case 4: // Fade. Parameters: tempo, endVol
     663                        case CONSTANT_BE_16(4): // Fade. Parameters: tempo, endVol
    664664                                // load the LSB of the 16bit words
    665665                                initFadeCommand(((const uint8 *)&trackData[2])[1], ((const int8 *)&trackData[3])[1]);
    666666                                break;
    667667
    668                         case 3: // Unknown, stops player aswell
     668                        case CONSTANT_BE_16(3): // Unknown, stops player aswell
    669669                        default:
    670670                                debug(3, "Tfmx: Unknown Trackstep Command: %02X", READ_BE_UINT16(&trackData[1]));
    671671                                // MI-Player handles this by stopping the player, we just continue