private void readPattern(BufferedInputStream in, Pattern p) throws IOException { // Pattern header length read(in, 4); // Packing type (always 0) in.read(); // Number of rows in pattern (1...256) int rows = make16Bit(read(in, 2)); // Packed patterndata size int size = make16Bit(read(in, 2)); int data[]; if (size == 0) { data = new int[0]; } else { byte[] b = read(in, size); data = new int[size]; for (int i = 0; i < size; i++) { data[i] = b[i]; } } p.setData(data); p.setRows(rows); }
private int updateData(Pattern pattern, int patternpos) { int[] data = pattern.getData(); if (data.length == 0) return patternpos; int check = data[patternpos++]; ud.reset(); if ((check & 0x80) != 0) { // note if ((check & 0x1) != 0) ud.setNote(data[patternpos++]); // instrument if ((check & 0x2) != 0) { int tmp = data[patternpos++] - 1; ud.setInstrument(mod.getModule().getInstrument(tmp)); } // volume if ((check & 0x4) != 0) ud.setVolume(data[patternpos++] & 0xff); // effect if ((check & 0x8) != 0) ud.setEffect(data[patternpos++]); // effect param if ((check & 0x10) != 0) ud.setEffectParameter(data[patternpos++] & 0xff); } else { ud.setNote(check); ud.setInstrument(mod.getModule().getInstrument(data[patternpos++] - 1)); ud.setVolume(data[patternpos++] & 0xff); ud.setEffect(data[patternpos++]); ud.setEffectParameter(data[patternpos++] & 0xff); } return patternpos; }
final int skip(Pattern pattern, int patternpos) { int[] data = pattern.getData(); if (data.length == 0) return patternpos; int check = data[patternpos++]; if ((check & 0x80) != 0) { if ((check & 0x1) != 0) patternpos++; if ((check & 0x2) != 0) patternpos++; if ((check & 0x4) != 0) patternpos++; if ((check & 0x8) != 0) patternpos++; if ((check & 0x10) != 0) patternpos++; } else { patternpos += 4; } return patternpos; }