Repair code for powermacg3 presets

This commit is contained in:
dingusdev 2020-08-30 16:14:58 -07:00
parent 2f2c9aadcb
commit 4f59407cd0
5 changed files with 31 additions and 12 deletions

View File

@ -1,6 +1,9 @@
#include "machineproperties.h"
#include "machinepresets.h"
#include "machinefactory.h"
#include "devices/memctrlbase.h"
#include <cmath>
#include <fstream>
#include <thirdparty/loguru/loguru.hpp>
void init_ppc_cpu_map() {
@ -139,7 +142,10 @@ void search_properties(std::string machine_str) {
std::cout << "GMEM SIZE: " << std::dec << gfx_size << std::endl;
}
bool establish_machine_settings(std::string machine_str, uint32_t* ram_sizes) {
bool establish_machine_presets(const char* rom_filepath, std::string machine_str, uint32_t* ram_sizes) {
ifstream rom_file;
uint32_t file_size;
init_ppc_cpu_map();
init_gpu_map();
init_machine_properties();
@ -147,6 +153,22 @@ bool establish_machine_settings(std::string machine_str, uint32_t* ram_sizes) {
//search_properties(machine_str);
rom_file.open(rom_filepath, ios::in | ios::binary);
if (rom_file.fail()) {
LOG_F(ERROR, "Cound not open the specified ROM file.");
rom_file.close();
return false;
}
if (file_size != 0x400000UL) {
LOG_F(ERROR, "Unxpected ROM File size. Expected size is 4 megabytes.");
rom_file.close();
return false;
}
load_rom(rom_file, file_size);
rom_file.close();
if (loop_ram_check (machine_str, ram_sizes)) {
return true;
}

View File

@ -75,7 +75,7 @@ int create_machine_for_id(uint32_t id, uint32_t* grab_ram_size, uint32_t gfx_siz
/* Read ROM file content and transfer it to the dedicated ROM region */
void load_rom(ifstream& rom_file, uint32_t file_size) {
void load_rom(std::ifstream& rom_file, uint32_t file_size) {
unsigned char* sysrom_mem = new unsigned char[file_size];
rom_file.seekg(0, ios::beg);

View File

@ -28,6 +28,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#define MACHINE_FACTORY_H
#include "machinebase.h"
#include <fstream>
void load_rom(std::ifstream& rom_file, uint32_t file_size);
int create_machine_for_rom(const char* rom_filepath, uint32_t* grab_ram_size, uint32_t gfx_size);

View File

@ -41,6 +41,6 @@ void init_gpu_map(); //JANKY FUNCTION TO FIX VS 2019 BUG!
uint32_t get_gfx_card(std::string gfx_str);
uint32_t get_cpu_type(std::string cpu_str);
void search_properties(uint32_t chosen_gestalt);
bool establish_machine_settings(std::string machine_str, uint32_t* ram_sizes);
bool establish_machine_presets(const char* rom_filepath, std::string machine_str, uint32_t* ram_sizes);
#endif /* MACHINE_PROPERTIES_H */

View File

@ -181,10 +181,10 @@ int main(int argc, char** argv) {
if (machine_specified) {
if (machine_name.compare("PowerMacG3") == 0) {
if (establish_machine_settings(machine_name, sys_ram_size)) {
if (establish_machine_presets(rom_file.c_str(), machine_name, sys_ram_size)) {
if (create_gossamer(sys_ram_size, gfx_mem)) {
goto bail;
}
}
} else {
LOG_F(ERROR, "Invalid Settings Specified");
return -1;
@ -199,15 +199,9 @@ int main(int argc, char** argv) {
return -1;
}
}
else{
else {
if (create_machine_for_rom(rom_file.c_str(), sys_ram_size, gfx_mem)) {
goto bail;
} else {
LOG_F(
WARNING,
"Could not create ROM, because the file %s was not found!", rom_file.c_str());
display_help();
return -1;
}
}