diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/CDTrackInfo.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/CDTrackInfo.java')
| -rw-r--r-- | NET/worlds/scape/CDTrackInfo.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/NET/worlds/scape/CDTrackInfo.java b/NET/worlds/scape/CDTrackInfo.java new file mode 100644 index 0000000..e3c35d9 --- /dev/null +++ b/NET/worlds/scape/CDTrackInfo.java @@ -0,0 +1,82 @@ +package NET.worlds.scape; + +public class CDTrackInfo { + private int[] pos; + private int[] len; + + public CDTrackInfo(int numTracks) { + this.pos = new int[numTracks]; + this.len = new int[numTracks]; + } + + public int getNumTracks() { + return this.pos.length; + } + + public int getStartFrames(int track) { + return this.getPosM(track) * 60 * 75 + this.getPosS(track) * 75 + this.getPosF(track); + } + + public int getEndFrames(int track) { + return track == this.pos.length - 1 + ? this.getStartFrames(track) + this.getLenM(track) * 60 * 75 + this.getLenS(track) * 75 + this.getLenF(track) + : this.getStartFrames(track + 1) - 1; + } + + public int getPosM(int track) { + return minutes(this.pos[track]); + } + + public int getPosS(int track) { + return seconds(this.pos[track]); + } + + public int getPosF(int track) { + return frames(this.pos[track]); + } + + public int getLenM(int track) { + return minutes(this.len[track]); + } + + public int getLenS(int track) { + return seconds(this.len[track]); + } + + public int getLenF(int track) { + return frames(this.len[track]); + } + + private static int minutes(int packed) { + return packed & 0xFF; + } + + private static int seconds(int packed) { + return packed >> 8 & 0xFF; + } + + private static int frames(int packed) { + return packed >> 16 & 0xFF; + } + + private static String format2(int val) { + String result = ""; + if (val < 10) { + result = "0"; + } + + return result + val; + } + + private static String format(int packed) { + return minutes(packed) + ":" + format2(seconds(packed)) + ":" + format2(frames(packed)); + } + + public void dump() { + System.out.println("Tracks: " + this.pos.length); + + for (int i = 0; i < this.pos.length; i++) { + System.out.println("Track " + i + " " + "start " + format(this.pos[i]) + " length " + format(this.len[i])); + } + } +} |