PSX游戏中获得的游戏ID [英] Getting game ID of psx game

查看:170
本文介绍了PSX游戏中获得的游戏ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这是从一个磁盘映像称号.ISO或.CUE +的.bin格式的最佳方式,
是否有任何Java库,可以做到这一点,或者我应该从文件头读取?

更新:
我设法做到这一点,我是在PSX ISO的标题特别感兴趣。这是10个字节长,这是一个示例code来阅读:

 文件f =新的文件(cdimage2.bin);
的FileInputStream鳍=新的FileInputStream(F);
fin.skip(37696);
INT I = 0;
而(ⅰ小于10){
    System.out.print((char)的fin.read());
    我++;
}
的System.out.println();

UPDATE2:这个方法比较好:

 私人字符串getPSXId(文件f){
的FileInputStream鳍;
尝试{
    鳍=新的FileInputStream(F);
    fin.skip(32768);
    字节[]缓冲区=新的字节[4096];
    长启动= System.currentTimeMillis的();
    而(fin.read(缓冲液)!= - 1){
        字符串缓冲=新的String(缓冲);        如果(buffered.contains(BOOT = CDROM:\\\\)){
            字符串TMP =;
            INT lidx = buffered.lastIndexOf(BOOT = CDROM:\\\\)+ 14;
            的for(int i = 0; I< 11;我++){
                TMP + = buffered.charAt(lidx + I);
            }
            经过长= System.currentTimeMillis的() - 启动;
            //的System.out.println(BOOT = CDROM:\\\\+ TMP);
            TMP = tmp.toUpperCase()取代(,。).replace(_, - )。
            fin.close();
            返回TMP;
        }    }
    fin.close();
}赶上(FileNotFoundException异常五){
    // TODO自动生成catch块
    e.printStackTrace();
}赶上(IOException异常五){
    // TODO自动生成catch块
    e.printStackTrace();
}返回null;}


解决方案

刚开始后的2048字节块(卷描述符)32768字节(通过ISO9660未使用)读书。第一个字节决定描述符的类型,而 1 办法主卷描述符,其中包含第一后标题7字节(它总是 \\ x01CD001 \\ X01 )。下一个字节是一个NUL( \\ X00 )和它后跟32字节系统和32字节卷标识符的,后者通常已知的,并且作为标题显示。请参见 http://alumnus.caltech.edu/~pje/iso9660.html 为更详细的说明。

I was wondering which is the best way to get the title from a disk image in .iso or .cue+.bin format, Is there any java library that can do this or should I read from the file header?

UPDATE: I managed to do it, i was particularly interested in PSX ISOs title. It's 10 bytes long and this is a sample code to read it:

File f = new File("cdimage2.bin");
FileInputStream fin = new FileInputStream(f);
fin.skip(37696);
int i = 0;
while (i < 10) {
    System.out.print((char) fin.read());
    i++;
}
System.out.println();

UPDATE2: This method is better:

private String getPSXId(File f) {
FileInputStream fin;
try {
    fin = new FileInputStream(f);
    fin.skip(32768);
    byte[] buffer = new byte[4096];
    long start = System.currentTimeMillis();
    while (fin.read(buffer) != -1) {
        String buffered = new String(buffer);

        if (buffered.contains("BOOT = cdrom:\\")) {
            String tmp = "";
            int lidx = buffered.lastIndexOf("BOOT = cdrom:\\") + 14;
            for (int i = 0; i < 11; i++) {
                tmp += buffered.charAt(lidx + i);
            }
            long elapsed = System.currentTimeMillis() - start;
            // System.out.println("BOOT = cdrom:\\" + tmp);
            tmp = tmp.toUpperCase().replace(".", "").replace("_", "-");
            fin.close();
            return tmp;
        }

    }
    fin.close();
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

return null;

}

解决方案

Just start reading after 32768 bytes (unused by ISO9660) in 2048 byte chunks (Volume Descriptor). The first byte determines the type of the descriptor, and 1 means Primary Volume Descriptor, which contain the title after the first 7 bytes (which are always \x01CD001\x01). The next byte is a NUL (\x00) and it is followed by 32 bytes of system and 32 bytes of volume identifier, the latter usually known and displayed as title. See http://alumnus.caltech.edu/~pje/iso9660.html for a more detailed description.

这篇关于PSX游戏中获得的游戏ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆