dingusppc/main.cpp

148 lines
5.5 KiB
C++
Raw Normal View History

/*
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/>.
*/
2020-05-12 18:55:45 +00:00
// The main runfile - main.cpp
// This is where the magic begins
2020-05-12 18:55:45 +00:00
#include "debugger/debugger.h"
#include "machines/machinefactory.h"
#include "ppcemu.h"
#include <cinttypes>
#include <cstring>
2020-03-26 19:32:24 +00:00
#include <fstream>
2020-05-12 18:55:45 +00:00
#include <iostream>
2020-03-26 19:32:24 +00:00
#include <sstream>
#include <stdio.h>
#include <thirdparty/SDL2/include/SDL.h>
2020-05-12 18:55:45 +00:00
#include <thirdparty/loguru/loguru.hpp>
using namespace std;
2020-05-12 18:55:45 +00:00
int main(int argc, char** argv) {
2020-08-22 18:05:08 +00:00
/*
Execution Type:
0 = Realtime (Interpreter)
1 = Realtime (Debugger)
2 = Recompiler (to-do)
The rest will be decided later
*/
uint32_t execution_mode = 0;
std::cout << "DingusPPC - Prototype 5bf5 (8/23/2020) " << endl;
std::cout << "Written by divingkatae and maximumspatium " << endl;
std::cout << "(c) 2018-2020 The DingusPPC Dev Team. " << endl;
std::cout << "This is not intended for general use. " << endl;
std::cout << "Use at your own discretion. " << endl;
2020-08-22 18:05:08 +00:00
if (argc < 1) {
std::cout << " " << endl;
std::cout << "Please enter one of the following commands when " << endl;
std::cout << "booting up DingusPPC... " << endl;
std::cout << " " << endl;
std::cout << "realtime - Run the emulator in real-time. " << endl;
std::cout << "debugger - Enter the interactive debugger. " << endl;
}
else {
2020-03-26 19:32:24 +00:00
std::string rom_file = "rom.bin", disk_file = "disk.img";
int ram_size = 64, gfx_mem = 2, video_card_vendor = 0x1002, video_card_id = 0x4750;
2020-08-22 18:05:08 +00:00
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 == "ram") || (checker == "/ram") || (checker == "-ram")) {
arg_loop++;
string ram_amount = argv[arg_loop];
ram_size = stoi(ram_amount);
LOG_F(INFO, "SYSTEM RAM set to: %d", ram_size);
2020-08-22 18:05:08 +00:00
}
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());
2020-03-26 19:32:24 +00:00
}
2020-08-22 18:05:08 +00:00
2020-03-26 19:32:24 +00:00
}
if (create_machine_for_rom(rom_file.c_str())) {
goto bail;
}
2020-03-19 14:09:24 +00:00
#ifdef SDL
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;
}
#endif
2020-08-22 18:05:08 +00:00
switch (execution_mode) {
case 0:
ppc_exec();
2020-08-22 18:05:08 +00:00
break;
case 1:
2019-07-17 13:24:34 +00:00
enter_debugger();
2020-08-22 18:05:08 +00:00
break;
default:
LOG_F(ERROR, "Invalid EXECUTION MODE");
return 1;
}
2020-08-22 18:05:08 +00:00
}
bail:
LOG_F(INFO, "Cleaning up...");
delete gMachineObj.release();
return 0;
}