WolPSX
Loading...
Searching...
No Matches
bios.cpp
1#include <fstream>
2
3#include "core/bios/bios.hpp"
4
12BIOS::BIOS(std::string path)
13{
14 //Make data a vector of size 512KB
15 data.resize(512 * 1024);
16
17 //Open the file
18 std::ifstream file(path, std::ios::binary);
19
20 //Check file size
21 file.seekg(0, std::ios::end);
22 std::streampos fileSize = file.tellg();
23 if (fileSize != BIOS_SIZE)
24 {
25 throw std::runtime_error("Invalid BIOS size");
26 }
27
28 //Read the file
29 file.seekg(0, std::ios::beg);
30 file.read((char *)data.data(), fileSize);
31 file.close();
32}
33
40uint32_t BIOS::read32_cpu(uint32_t offset)
41{
42 //since the system is little endian, we can do this
43 return *(uint32_t *)&data[offset];
44
45 //TODO: add compatibility for big endian systems
46}
47
54uint8_t BIOS::read8_cpu(uint32_t offset)
55{
56 return data[offset];
57}
uint32_t read32_cpu(uint32_t offset)
Reads a 32-bit word from the BIOS.
Definition bios.cpp:40
uint8_t read8_cpu(uint32_t offset)
Reads a 8-bit word from the BIOS.
Definition bios.cpp:54
std::vector< uint8_t > data
Data of the BIOS.
Definition bios.hpp:27
BIOS(std::string path)
Construct a new BIOS:: BIOS object.
Definition bios.cpp:12