Fixed booting up to emulator

This commit is contained in:
dingusdev 2020-10-04 09:58:21 -07:00
parent 55ea643974
commit 0ca03be001
3 changed files with 36 additions and 133 deletions

View File

@ -45,13 +45,18 @@ bool check_ram_size(std::string machine_str, uint32_t number_to_check) {
uint32_t min_ram = 8;
uint32_t max_ram = 16;
if (machine_str.compare("PowerMacG3") == 0) {
if (machine_str.compare("pmg3") == 0) {
min_ram = PowerMacG3_Properties.find("minram")->second.IntRep();
max_ram = PowerMacG3_Properties.find("maxram")->second.IntRep();
}
if (number_to_check == 0) {
LOG_F(WARNING, "EMPTY RAM BANK ERROR - size %d", number_to_check);
return true;
}
if ((number_to_check > max_ram) ||
(number_to_check > max_ram) ||
(number_to_check < min_ram) ||
!(is_power_of_two(number_to_check))) {
return false;
}
@ -71,6 +76,7 @@ bool loop_ram_check(std::string machine_str, uint32_t* ram_sizes) {
}
if (check_ram_size(machine_str, ram_sizes[checking_stage_one]) == false) {
LOG_F(ERROR, "RAM BANK ERROR with RAM BANK %d", checking_stage_one);
cout << machine_str << endl;
return false;
}
}
@ -103,10 +109,6 @@ void search_properties(std::string machine_str) {
std::cerr << "Unable to find congifuration for " << machine_str << std::endl;
}
uint16_t gfx_ven = gfx_type >> 16;
uint16_t gfx_dev = gfx_type & 0xFFFF;
std::cout << "CPU TYPE: 0x" << std::hex << cpu_type << std::endl;
std::cout << "RAM SIZE: " << std::dec << ram_size << std::endl;
std::cout << "GMEM SIZE: " << std::dec << gfx_size << std::endl;
@ -128,6 +130,7 @@ int establish_machine_presets(
return -1;
}
rom_file.seekg(0, rom_file.end);
file_size = rom_file.tellg();
rom_file.seekg(0, rom_file.beg);
@ -139,7 +142,7 @@ int establish_machine_presets(
}
if (loop_ram_check(machine_str, ram_sizes) == true) {
if (machine_str.compare("PowerMacG3") == 0) {
if (machine_str.compare("pmg3") == 0) {
create_gossamer(ram_sizes, gfx_mem);
}
}

View File

@ -6,7 +6,7 @@ static std::map<std::string, StrProperty> PowerMac6100_Properties = {
{"cputype", StrProperty("PPC_MPC750")},
{"motherboard", StrProperty("Grackle")},
{"ioboard", StrProperty("Heathrow")},
{"rambank1", StrProperty("64")},
{"rambank1", StrProperty("8")},
{"minram", StrProperty("32")},
{"maxram", StrProperty("256")},
{"gfxcard", StrProperty("Nubus_Video")},

150
main.cpp
View File

@ -80,7 +80,6 @@ int main(int argc, char** argv) {
uint32_t execution_mode = 0;
uint32_t sys_ram_size[12] = {64, 0, 0, 0};
uint32_t gfx_mem = 2;
bool machine_specified = false;
string machine_name = "";
CLI::App app("DingusPPC CLI");
@ -138,13 +137,26 @@ int main(int argc, char** argv) {
if (*machine_opt) {
LOG_F(INFO, "Machine option was passed in: %s", machine_str.c_str());
create_machine_for_rom(bootrom_path.c_str(), sys_ram_size, gfx_mem);
} else {
machine_str = machine_name_from_rom(bootrom_path);
if (machine_str.empty()) {
LOG_F(ERROR, "Could not autodetect machine");
return 0;
}
else {
LOG_F(INFO, "Machine was autodetected as: %s", machine_str.c_str());
if (machine_str.compare("pmg3") == 0) {
LOG_F(INFO, "Time to build up a machine");
establish_machine_presets(bootrom_path.c_str(), machine_str, sys_ram_size, gfx_mem);
} else if (machine_str.compare("pm6100") == 0) {
LOG_F(ERROR, "Board not yet ready for: %s", machine_str.c_str());
return -1;
} else {
cout << "Unable to define machine: " << machine_str << endl;
return -1;
}
}
LOG_F(INFO, "Machine was autodetected as: %s", machine_str.c_str());
}
/* handle overriding of machine settings from CLI */
@ -164,145 +176,33 @@ int main(int argc, char** argv) {
cout << "BootROM path: " << bootrom_path << endl;
cout << "Execution mode: " << execution_mode << endl;
return 0;
if (argc < 1) {
display_help();
return 0;
}
else {
std::string rom_file = "rom.bin", disk_file = "disk.img";
int video_card_vendor = 0x1002, video_card_id = 0x4750;
for (int arg_loop = 1; arg_loop < argc; arg_loop++) {
string checker = argv[arg_loop];
cout << checker << endl;
if ((checker == "realtime") || (checker == "-realtime") || (checker == "/realtime")) {
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
loguru::g_preamble_date = false;
loguru::g_preamble_time = false;
loguru::g_preamble_thread = false;
loguru::init(argc, argv);
loguru::add_file("dingusppc.log", loguru::Append, 0);
// Replace the above line with this for maximum debugging detail:
// loguru::add_file("dingusppc.log", loguru::Append, loguru::Verbosity_MAX);
execution_mode = 0;
} else if ((checker == "debugger") || (checker == "/debugger") || (checker == "-debugger")) {
loguru::g_stderr_verbosity = 0;
loguru::g_preamble_date = false;
loguru::g_preamble_time = false;
loguru::g_preamble_thread = false;
loguru::init(argc, argv);
execution_mode = 1;
}
else if ((checker == "help") || (checker == "/help") || (checker == "-help")) {
display_help();
return 0;
}
else if ((checker == "pmg3") || (checker == "/pmg3") || (checker == "-pmg3")) {
machine_name = "PowerMacG3";
machine_specified = true;
}
else if ((checker == "pm6100") || (checker == "/pm6100") || (checker == "-pm6100")) {
machine_name = "PowerMac6100";
machine_specified = true;
}
else if ((checker == "machinehelp") || (checker == "/machinehelp") || (checker == "-machinehelp")) {
machine_name = "MachineHelp";
machine_specified = true;
}
else if ((checker == "ram") || (checker == "/ram") || (checker == "-ram")) {
arg_loop++;
string ram_banks = argv[arg_loop];
uint32_t ram_loop = stoi(ram_banks);
for (int check_loop = 0; check_loop < ram_loop; check_loop++) {
sys_ram_size[check_loop] = stoi(argv[arg_loop]);
}
}
else if ((checker == "gfxmem") || (checker == "/gfxmem") || (checker == "-gfxmem")) {
arg_loop++;
string vram_amount = argv[arg_loop];
gfx_mem = stoi(vram_amount);
LOG_F(INFO, "GFX MEMORY set to: %d", gfx_mem);
}
else if ((checker == "romfile") || (checker == "/romfile") || (checker == "-romfile")) {
arg_loop++;
rom_file = argv[arg_loop];
LOG_F(INFO, "ROM FILE will now be: %s", rom_file.c_str());
}
else if ((checker == "diskimg") || (checker == "/diskimg") || (checker == "-diskimg")) {
arg_loop++;
rom_file = argv[arg_loop];
LOG_F(INFO, "Load the DISK IMAGE from: %s", rom_file.c_str());
}
else if ((checker == "videocard") || (checker == "/videocard") || (checker == "-videocard")) {
arg_loop++;
string check_card = argv[arg_loop];
if (checker.compare("RagePro") == 0) {
video_card_vendor = 0x1002;
video_card_id = 0x4750;
}
else if (checker.compare("Rage128") == 0) {
video_card_vendor = 0x1002;
video_card_id = 0x5046;
}
else if (checker.compare("Radeon7000") == 0) {
video_card_vendor = 0x1002;
video_card_id = 0x5159;
}
}
}
if (machine_specified) {
if (machine_name.compare("PowerMacG3") == 0) {
LOG_F(INFO, "Time to build up a machine");
if (establish_machine_presets(rom_file.c_str(), machine_name, sys_ram_size, gfx_mem)) {
goto bail;
}
}
else if (machine_name.compare("PowerMac6100") == 0) {
LOG_F(ERROR, "Board not yet ready for: %s", machine_name.c_str());
return -1;
}
else {
display_recognized_machines();
return -1;
}
}
else {
if (create_machine_for_rom(rom_file.c_str(), sys_ram_size, gfx_mem)) {
goto bail;
}
}
#ifdef SDL
if (SDL_Init(SDL_INIT_AUDIO)){
LOG_F(ERROR, "SDL_Init error: %s", SDL_GetError());
goto bail;
return 0;
}
#endif
switch (execution_mode) {
switch (execution_mode) {
case 0:
ppc_exec();
for (;;) {
ppc_exec();
}
break;
case 1:
enter_debugger();
break;
default:
LOG_F(ERROR, "Invalid EXECUTION MODE");
return 1;
}
return 0;
}
bail:
/*
bail:
LOG_F(INFO, "Cleaning up...");
delete gMachineObj.release();
return 0;
*/
}