diff --git a/cpu/ppc/poweropcodes.cpp b/cpu/ppc/poweropcodes.cpp index 07c5024..731b563 100644 --- a/cpu/ppc/poweropcodes.cpp +++ b/cpu/ppc/poweropcodes.cpp @@ -24,11 +24,9 @@ along with this program. If not, see . #include "ppcemu.h" #include "ppcmmu.h" -#include #include #include #include -#include #include #include diff --git a/devices/atirage.cpp b/devices/atirage.cpp index e85f0e6..26ab260 100644 --- a/devices/atirage.cpp +++ b/devices/atirage.cpp @@ -28,9 +28,8 @@ along with this program. If not, see . #include -ATIRage::ATIRage(uint16_t dev_id) : PCIDevice("ati-rage") -{ - this->vram_size = 0x200000; /* FIXME: hardcoded VRAM size! */ +ATIRage::ATIRage(uint16_t dev_id, uint32_t mem_amount) : PCIDevice("ati-rage") { + this->vram_size = mem_amount << 20; /*allocate video RAM */ this->vram_ptr = new uint8_t[this->vram_size]; diff --git a/devices/atirage.h b/devices/atirage.h index 60b6d70..9cbf72e 100644 --- a/devices/atirage.h +++ b/devices/atirage.h @@ -111,7 +111,7 @@ constexpr auto MEMMAP_OFFSET = 0x007FFC00UL; /* offset to memory mapped register class ATIRage : public PCIDevice { public: - ATIRage(uint16_t dev_id); + ATIRage(uint16_t dev_id, uint32_t mem_amount); ~ATIRage(); /* MMIODevice methods */ diff --git a/machines/machineconfig.cpp b/machines/machineconfig.cpp index 46b5757..2664474 100644 --- a/machines/machineconfig.cpp +++ b/machines/machineconfig.cpp @@ -16,7 +16,7 @@ void init_gpu_map() { } void init_machine_properties() { - PowerMac6100_Properties.emplace("machineid", StringProperty("Nubus Power Mac")); + PowerMac6100_Properties.emplace("machineid", StringProperty("PowerMac6100")); PowerMac6100_Properties.emplace("cputype", StringProperty("PPC_MPC601")); PowerMac6100_Properties.emplace("motherboard", StringProperty("Nubus")); PowerMac6100_Properties.emplace("ioboard", StringProperty("Nubus_IO")); @@ -25,7 +25,7 @@ void init_machine_properties() { PowerMac6100_Properties.emplace("gfxmem", StringProperty("1")); - PowerMacG3_Properties.emplace("machineid", StringProperty("Power Mac G3 Beige")); + PowerMacG3_Properties.emplace("machineid", StringProperty("PowerMacG3")); PowerMacG3_Properties.emplace("cputype", StringProperty("PPC_MPC750")); PowerMacG3_Properties.emplace("motherboard", StringProperty("Grackle")); PowerMacG3_Properties.emplace("ioboard", StringProperty("Heathrow")); diff --git a/machines/machinefactory.cpp b/machines/machinefactory.cpp index 54c0759..32128c0 100644 --- a/machines/machinefactory.cpp +++ b/machines/machinefactory.cpp @@ -61,10 +61,10 @@ static const map rom_identity = { }; -int create_machine_for_id(uint32_t id) { +int create_machine_for_id(uint32_t id, uint32_t* grab_ram_size, uint32_t gfx_size) { switch (id) { case 0x476F7373: - create_gossamer(); + create_gossamer(grab_ram_size, gfx_size); break; default: LOG_F(ERROR, "Unknown machine ID: %X", id); @@ -89,7 +89,7 @@ void load_rom(ifstream& rom_file, uint32_t file_size) { } -int create_machine_for_rom(const char* rom_filepath) { +int create_machine_for_rom(const char* rom_filepath, uint32_t* grab_ram_size, uint32_t gfx_size) { ifstream rom_file; uint32_t file_size, config_info_offset, rom_id; char rom_id_str[17]; @@ -136,7 +136,7 @@ int create_machine_for_rom(const char* rom_filepath) { LOG_F(INFO, "The machine is identified as... %s\n", rom_identity.at(rom_id).c_str()); - create_machine_for_id(rom_id); + create_machine_for_id(rom_id, grab_ram_size, gfx_size); load_rom(rom_file, file_size); diff --git a/machines/machinefactory.h b/machines/machinefactory.h index eb349c1..9d17334 100644 --- a/machines/machinefactory.h +++ b/machines/machinefactory.h @@ -29,8 +29,8 @@ along with this program. If not, see . #include "machinebase.h" -int create_machine_for_rom(const char* rom_filepath); +int create_machine_for_rom(const char* rom_filepath, uint32_t* grab_ram_size, uint32_t gfx_size); -int create_gossamer(void); +int create_gossamer(uint32_t* grab_ram_size, uint32_t gfx_size); #endif /* MACHINE_FACTORY_H */ diff --git a/machines/machinegossamer.cpp b/machines/machinegossamer.cpp index ddf022e..c12346b 100644 --- a/machines/machinegossamer.cpp +++ b/machines/machinegossamer.cpp @@ -33,6 +33,7 @@ along with this program. If not, see . #include "devices/spdram.h" #include "devices/viacuda.h" #include "machinebase.h" +#include "machineproperties.h" #include static void setup_ram_slot(std::string name, int i2c_addr, int capacity_megs) { @@ -49,7 +50,7 @@ static void setup_ram_slot(std::string name, int i2c_addr, int capacity_megs) { } -int create_gossamer() { +int create_gossamer(uint32_t* grab_ram_size, uint32_t gfx_size) { if (gMachineObj) { LOG_F(ERROR, "Global machine object not empty!"); return -1; @@ -86,12 +87,12 @@ int create_gossamer() { } /* configure RAM slots */ - setup_ram_slot("RAM_DIMM_1", 0x57, 64); /* RAM slot 1 -> 64MB by default */ - setup_ram_slot("RAM_DIMM_2", 0x56, 0); /* RAM slot 2 -> empty by default */ - setup_ram_slot("RAM_DIMM_3", 0x55, 0); /* RAM slot 3 -> empty by default */ + setup_ram_slot("RAM_DIMM_1", 0x57, grab_ram_size[0]); /* RAM slot 1 -> 64MB by default */ + setup_ram_slot("RAM_DIMM_2", 0x56, grab_ram_size[1]); /* RAM slot 2 -> empty by default */ + setup_ram_slot("RAM_DIMM_3", 0x55, grab_ram_size[2]); /* RAM slot 3 -> empty by default */ /* register ATI 3D Rage Pro video card with the PCI host bridge */ - gMachineObj->add_component("ATIRage", new ATIRage(ATI_RAGE_PRO_DEV_ID)); + gMachineObj->add_component("ATIRage", new ATIRage(ATI_RAGE_PRO_DEV_ID, gfx_size)); grackle_obj->pci_register_device( 18, dynamic_cast(gMachineObj->get_comp_by_name("ATIRage"))); diff --git a/machines/machinepresets.h b/machines/machinepresets.h index 698a3fc..97c0f54 100644 --- a/machines/machinepresets.h +++ b/machines/machinepresets.h @@ -4,6 +4,8 @@ std::map PowerMac6100_Properties; std::map PowerMacG3_Properties; -void init_machine_properties(); // JANKY FUNCTION TO FIX VS 2019 BUG! +map PPC_CPUs; -#define ILLEGAL_DEVICE_VALUE 0x168A523B \ No newline at end of file +map GFX_CARDs; + +void init_machine_properties(); // JANKY FUNCTION TO FIX VS 2019 BUG! \ No newline at end of file diff --git a/machines/machineproperties.h b/machines/machineproperties.h index af5dbac..6ecc58e 100644 --- a/machines/machineproperties.h +++ b/machines/machineproperties.h @@ -1,16 +1,16 @@ - -#ifndef MACHINE_PROPERTIES_H -#define MACHINE_PROPERTIES_H - #include "endianswap.h" #include -#include +#include #include #include #include +#ifndef MACHINE_PROPERTIES_H +#define MACHINE_PROPERTIES_H using namespace std; +#define ILLEGAL_DEVICE_VALUE 0x168A523B + class StringProperty { public: StringProperty(string EnterString) { @@ -27,21 +27,12 @@ public: } catch (string bad_string) { cerr << "Could not convert string " << bad_string << "to an ineteger!" << endl; - return 0x168A523B; + return ILLEGAL_DEVICE_VALUE; } } private: - string StringInput = "0x168A523B"; -}; - -map PPC_CPUs; - -map GFX_CARDs; - -enum GESTALT : uint32_t { - pm6100 = 100, - pmg3 = 510, + string StringInput = std::to_string(ILLEGAL_DEVICE_VALUE); }; void init_ppc_cpu_map(); //JANKY FUNCTION TO FIX VS 2019 BUG! diff --git a/main.cpp b/main.cpp index b4b3f04..5d1c698 100644 --- a/main.cpp +++ b/main.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . #include "debugger/debugger.h" #include "machines/machinefactory.h" +#include "machines/machineproperties.h" #include "ppcemu.h" #include #include @@ -36,6 +37,24 @@ along with this program. If not, see . using namespace std; +void display_help() { + std::cout << " " << endl; + std::cout << "To interact with DingusPPC, please refer to the " << endl; + std::cout << "following command line reference guide: " << endl; + std::cout << "___________________________________________________" << endl; + std::cout << "| COMMAND | FUNCTION |" << endl; + std::cout << "___________________________________________________" << endl; + std::cout << " realtime | Run the emulator in real-time " << endl; + std::cout << " debugger | Enter the interactive debugger " << endl; + std::cout << " ram | Specify the number of RAM banks, " << endl; + std::cout << " | followed by how much each bank holds " << endl; + std::cout << " videocard | Specify the video card to emulate " << endl; + std::cout << " gfxmem | Specify the how much memory " << endl; + std::cout << " | to allocate to the emulated video card" << endl; + std::cout << " romfile | Insert the ROM file to use " << endl; + std::cout << " " << endl; +} + int main(int argc, char** argv) { /* Execution Type: @@ -46,7 +65,10 @@ int main(int argc, char** argv) { The rest will be decided later */ - uint32_t execution_mode = 0; + uint32_t execution_mode = 0; + uint32_t sys_ram_size[12] = {64, 0, 0, 0}; + uint32_t gfx_mem = 2; + bool machine_specified = false; std::cout << "DingusPPC - Prototype 5bf5 (8/23/2020) " << endl; std::cout << "Written by divingkatae and maximumspatium " << endl; @@ -55,17 +77,14 @@ int main(int argc, char** argv) { std::cout << "Use at your own discretion. " << endl; 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; + display_help(); + + return 0; } else { 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; + int video_card_vendor = 0x1002, video_card_id = 0x4750; for (int arg_loop = 1; arg_loop < argc; arg_loop++) { string checker = argv[arg_loop]; @@ -91,10 +110,12 @@ int main(int argc, char** argv) { } 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); - } + 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]; @@ -110,12 +131,30 @@ int main(int argc, char** argv) { 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 (create_machine_for_rom(rom_file.c_str())) { - goto bail; + if (!machine_specified) { + if (create_machine_for_rom(rom_file.c_str(), sys_ram_size, gfx_mem)) { + goto bail; + } } #ifdef SDL