| 813 | } |
| 814 | |
| 815 | void Emulator::LoadImageData(Nes::User::File& context) const |
| 816 | { |
| 817 | Path path( settings.paths.save ); |
| 818 | |
| 819 | cstring desc = "image save"; |
| 820 | |
| 821 | switch (context.GetAction()) |
| 822 | { |
| 823 | case Nes::User::File::LOAD_BATTERY: |
| 824 | |
| 825 | desc = "battery"; |
| 826 | break; |
| 827 | |
| 828 | case Nes::User::File::LOAD_EEPROM: |
| 829 | |
| 830 | desc = "EEPROM"; |
| 831 | break; |
| 832 | |
| 833 | case Nes::User::File::LOAD_TAPE: |
| 834 | |
| 835 | desc = "tape"; |
| 836 | path = settings.paths.tape; |
| 837 | break; |
| 838 | |
| 839 | case Nes::User::File::LOAD_TURBOFILE: |
| 840 | |
| 841 | desc = "turbo file"; |
| 842 | |
| 843 | if (path.Length()) |
| 844 | path.Extension() = L"tf"; |
| 845 | |
| 846 | break; |
| 847 | } |
| 848 | |
| 849 | if (path.FileExists()) |
| 850 | { |
| 851 | try |
| 852 | { |
| 853 | Io::Stream::In stream( path ); |
| 854 | const Nes::Result result = context.SetContent( stream ); |
| 855 | |
| 856 | if (NES_SUCCEEDED(result)) |
| 857 | { |
| 858 | Io::Log() << "Emulator: loaded " << desc << " data from \"" << path << "\"\r\n"; |
| 859 | } |
| 860 | else |
| 861 | { |
| 862 | HeapString msg( Resource::String( IDS_CARTRIDGE_LOAD_FAILED ).Invoke( path ) ); |
| 863 | |
| 864 | if (const uint id = ResultToString( result )) |
| 865 | msg << ' ' << Resource::String( id ); |
| 866 | |
| 867 | Window::User::Warn( msg.Ptr() ); |
| 868 | } |
| 869 | } |
| 870 | catch (Io::File::Exception id) |
| 871 | { |
| 872 | HeapString msg; |
no test coverage detected