2020-02-28 16:04:28 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
|
|
|
Copyright (C) 2018-20 divingkatae and maximum
|
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-07-02 02:15:33 +00:00
|
|
|
|
|
|
|
//The main runfile - main.cpp
|
|
|
|
//This is where the magic begins
|
|
|
|
|
2020-03-23 03:15:12 +00:00
|
|
|
#include <thirdparty/loguru/loguru.hpp>
|
2019-07-02 02:15:33 +00:00
|
|
|
#include <iostream>
|
2020-03-26 19:32:24 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
2019-07-02 02:15:33 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <cinttypes>
|
|
|
|
#include <stdio.h>
|
2019-12-27 19:10:36 +00:00
|
|
|
#include "ppcemu.h"
|
2019-12-14 12:48:54 +00:00
|
|
|
#include "debugger/debugger.h"
|
2020-03-13 21:49:58 +00:00
|
|
|
#include "machines/machinefactory.h"
|
2020-03-23 03:15:12 +00:00
|
|
|
#include <thirdparty/SDL2/include/SDL.h>
|
2019-07-02 02:15:33 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
|
2019-07-12 05:27:14 +00:00
|
|
|
std::cout << "DingusPPC - Prototype 5bf4 (7/14/2019) " << endl;
|
2019-07-02 02:15:33 +00:00
|
|
|
std::cout << "Written by divingkatae, (c) 2019. " << endl;
|
|
|
|
std::cout << "This is not intended for general use. " << endl;
|
|
|
|
std::cout << "Use at your own discretion. " << endl;
|
|
|
|
|
2020-02-27 02:51:07 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
string checker = argv[1];
|
|
|
|
cout << checker << endl;
|
2020-02-24 03:59:10 +00:00
|
|
|
|
2020-02-27 02:51:07 +00:00
|
|
|
if ((checker == "1") || (checker == "realtime") || \
|
|
|
|
(checker == "-realtime") || (checker == "/realtime")) {
|
|
|
|
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
|
2020-02-28 01:41:02 +00:00
|
|
|
loguru::g_preamble_date = false;
|
|
|
|
loguru::g_preamble_time = false;
|
|
|
|
loguru::g_preamble_thread = false;
|
2020-02-27 02:51:07 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
else if ((checker == "debugger") || (checker == "/debugger") ||
|
|
|
|
(checker == "-debugger")) {
|
|
|
|
loguru::g_stderr_verbosity = 0;
|
2020-02-28 01:41:02 +00:00
|
|
|
loguru::g_preamble_date = false;
|
|
|
|
loguru::g_preamble_time = false;
|
|
|
|
loguru::g_preamble_thread = false;
|
|
|
|
loguru::init(argc, argv);
|
2020-02-27 02:51:07 +00:00
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-03-26 19:32:24 +00:00
|
|
|
std::string rom_file = "rom.bin", disk_file = "disk.img";
|
|
|
|
int ram_size = 64, machine_gestalt = 510, video_card_vendor = 0x1002, video_card_id = 0x4750;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-03-26 19:32:24 +00:00
|
|
|
std::ifstream config_input("config.txt");
|
|
|
|
std::string line;
|
|
|
|
std::istringstream sin;
|
|
|
|
|
|
|
|
if (!config_input) {
|
|
|
|
LOG_F(ERROR, "Could not open config.txt. Creating a dummy config.txt now.");
|
|
|
|
std::ofstream config_output("config.txt");
|
2020-03-26 19:38:00 +00:00
|
|
|
|
2020-03-26 19:32:24 +00:00
|
|
|
config_output.write("rompath=rom.bin\n", 17);
|
|
|
|
config_output.write("diskpath=disk.img\n", 19);
|
|
|
|
config_output.write("ramsize=64\n", 12);
|
|
|
|
config_output.write("machine_gestalt=510\n", 21);
|
|
|
|
config_output.write("video_vendor=0x1002\n", 21);
|
|
|
|
config_output.write("video_card=0x4750\n", 19);
|
2020-03-26 19:38:00 +00:00
|
|
|
|
2020-03-26 19:32:24 +00:00
|
|
|
config_output.close();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (std::getline(config_input, line)) {
|
|
|
|
sin.str(line.substr(line.find("=") + 1));
|
|
|
|
if (line.find("rompath") != std::string::npos) {
|
|
|
|
sin >> rom_file;
|
|
|
|
}
|
|
|
|
else if (line.find("diskpath") != std::string::npos) {
|
|
|
|
sin >> disk_file;
|
|
|
|
}
|
|
|
|
else if (line.find("ramsize") != std::string::npos) {
|
|
|
|
sin >> ram_size;
|
|
|
|
}
|
|
|
|
else if (line.find("machine_gestalt") != std::string::npos) {
|
|
|
|
sin >> machine_gestalt;
|
|
|
|
}
|
|
|
|
else if (line.find("video_vendor") != std::string::npos) {
|
|
|
|
sin >> video_card_vendor;
|
|
|
|
}
|
|
|
|
else if (line.find("video_card") != std::string::npos) {
|
|
|
|
sin >> video_card_id;
|
|
|
|
}
|
|
|
|
sin.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create_machine_for_rom(rom_file.c_str())) {
|
2020-03-13 21:49:58 +00:00
|
|
|
goto bail;
|
2020-02-27 02:51:07 +00:00
|
|
|
}
|
2020-03-19 14:09:24 +00:00
|
|
|
|
|
|
|
if (SDL_Init(SDL_INIT_AUDIO)){
|
|
|
|
LOG_F(ERROR, "SDL_Init error: %s", SDL_GetError());
|
|
|
|
goto bail;
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-02-27 02:51:07 +00:00
|
|
|
if ((checker == "1") || (checker == "realtime") || \
|
|
|
|
(checker == "-realtime") || (checker == "/realtime")) {
|
2019-12-28 01:49:58 +00:00
|
|
|
ppc_exec();
|
2020-01-28 01:20:18 +00:00
|
|
|
} else if ((checker == "debugger") || (checker == "/debugger") ||
|
|
|
|
(checker == "-debugger")) {
|
2019-07-17 13:24:34 +00:00
|
|
|
enter_debugger();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-28 01:20:18 +00:00
|
|
|
else {
|
2020-02-28 01:41:02 +00:00
|
|
|
std::cout << " " << endl;
|
2019-07-07 06:10:32 +00:00
|
|
|
std::cout << "Please enter one of the following commands when " << endl;
|
|
|
|
std::cout << "booting up DingusPPC... " << endl;
|
2020-02-28 01:41:02 +00:00
|
|
|
std::cout << " " << endl;
|
|
|
|
std::cout << " " << endl;
|
2019-07-07 06:10:32 +00:00
|
|
|
std::cout << "realtime - Run the emulator in real-time. " << endl;
|
2019-07-19 06:31:16 +00:00
|
|
|
std::cout << "debugger - Enter the interactive debugger. " << endl;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-03-13 21:49:58 +00:00
|
|
|
bail:
|
|
|
|
LOG_F(INFO, "Cleaning up...");
|
|
|
|
|
|
|
|
delete gMachineObj.release();
|
2019-07-02 02:15:33 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|