public static int decodeAnimationBytes( byte prgsection[], int offset, CHREditorModel modelRef) {
        int cnt = 0;
        int numAnimations = prgsection[offset + cnt] & 0xFF; cnt++;
        int animDuration = prgsection[offset+cnt] & 0xFF;  cnt++;    
        int animGrid[][] = new int[numAnimations][animDuration];
        for(int i=0;i<numAnimations;i++) {
            for(int j=0;j<animDuration;j++){
               animGrid[i][j] = prgsection[offset+cnt] & 0xFF;  cnt++;    
            }
        }
        
        int numKfs = prgsection[offset+cnt] & 0xFF;  cnt++;  
        AnimationKeyframeData kfs[] = new AnimationKeyframeData[numKfs];
        // now extract the keyframes
        for(int i=0;i<numKfs;i++){
            kfs[i] = new AnimationKeyframeData();
            kfs[i].yPos = prgsection[offset+cnt];  cnt++;
            kfs[i].spriteIndex = prgsection[offset+cnt];  cnt++;
            kfs[i].setSpriteAttributesByte(prgsection[offset+cnt]);cnt++;
            kfs[i].xPos = prgsection[offset+cnt];  cnt++;            
        }
        for(int i=0;i<animGrid.length;i++) {
            modelRef.addAnimation();
            for(int j=0;j<animGrid[i].length;j++){
                int val = animGrid[i][j];
                if(val != 0) {
                    AnimationKeyframeData kf = modelRef.constructKeyFrame(i,j);
                    kfs[val-1].copyInto(kf);
                }
            }
        }        
        
        return cnt;
    }