tvOS istream失败

时间:2015-10-25 21:08:28

标签: c++ swift tvos

我试图在tvOS上运行Nestopia NES Emulation library但每次尝试加载其数据库或游戏文件时都会暂停

void In::SafeRead(byte* data,dword size) {
    static_cast<std::istream*>(stream)->read( reinterpret_cast<char*>(data), size);
}

没有任何控制台输出和EXC_BAD_ACCESS(代码= 1地址= 0xffffffff00000000)

这是我的ViewController

class ViewController: UIViewController {
    let emuWidth: CGFloat = 341.0
    let emuHeight: CGFloat = 320.0

    var emulatorCore: EmulatorCore!
    var emulatorView: ScreenView!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.emulatorView = ScreenView(frame: CGRectMake(0, 0, emuWidth, emuHeight))
        self.emulatorView.backgroundColor = UIColor.blackColor()
        self.view.addSubview(self.emulatorView)

        self.emulatorCore = EmulatorCore()
        self.emulatorCore.initializeEmulator()
        self.emulatorCore.frameBufferSize = CGSizeMake(emuWidth, emuHeight)

        do {
            let fileManager = NSFileManager.defaultManager()

            if !fileManager.fileExistsAtPath((NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("NstDatabase.dat")) {
                try NSFileManager.defaultManager().copyItemAtPath(NSBundle.mainBundle().pathForResource("NstDatabase", ofType: "dat")!, toPath: (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("NstDatabase.dat"))
            }

            if !fileManager.fileExistsAtPath((NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("mega_man.nes")) {
                try NSFileManager.defaultManager().copyItemAtPath(NSBundle.mainBundle().pathForResource("mega_man", ofType: "nes")!, toPath: (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("mega_man.nes"))
            }
        } catch _ {
            print("Error copying files!")
        }

        if self.emulatorCore.loadROM((NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("mega_man.nes")) {
            self.emulatorCore.configureEmulator()
            self.emulatorCore.screenDelegate = self.emulatorView
            self.emulatorCore.frameBufferAddress = self.emulatorView.frameBufferAddress

            self.emulatorView.delegate = self.emulatorCore
        } else {
            print("Error: invalid game path")
        }
    }
}

相同的代码在iOS上运行得很好。

谢谢!

0 个答案:

没有答案