CLI fixes - RAM and GFXMEM work better

This commit is contained in:
dingusdev 2020-08-25 20:07:02 -07:00
parent f04ce09a7d
commit 14ef7564cd
10 changed files with 81 additions and 51 deletions

View File

@ -24,11 +24,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "ppcemu.h"
#include "ppcmmu.h"
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <stdexcept>
#include <stdio.h>
#include <thirdparty/loguru/loguru.hpp>

View File

@ -28,9 +28,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <thirdparty/loguru/loguru.hpp>
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];

View File

@ -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 */

View File

@ -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"));

View File

@ -61,10 +61,10 @@ static const map<uint32_t, string> 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);

View File

@ -29,8 +29,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#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 */

View File

@ -33,6 +33,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "devices/spdram.h"
#include "devices/viacuda.h"
#include "machinebase.h"
#include "machineproperties.h"
#include <thirdparty/loguru/loguru.hpp>
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<PCIDevice*>(gMachineObj->get_comp_by_name("ATIRage")));

View File

@ -4,6 +4,8 @@ std::map<std::string, StringProperty> PowerMac6100_Properties;
std::map<std::string, StringProperty> PowerMacG3_Properties;
void init_machine_properties(); // JANKY FUNCTION TO FIX VS 2019 BUG!
map<string, uint32_t> PPC_CPUs;
#define ILLEGAL_DEVICE_VALUE 0x168A523B
map<string, uint32_t> GFX_CARDs;
void init_machine_properties(); // JANKY FUNCTION TO FIX VS 2019 BUG!

View File

@ -1,16 +1,16 @@
#ifndef MACHINE_PROPERTIES_H
#define MACHINE_PROPERTIES_H
#include "endianswap.h"
#include <cinttypes>
#include <cstring>
#include <string>
#include <map>
#include <iostream>
#include <utility>
#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<string, uint32_t> PPC_CPUs;
map<string, uint32_t> 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!

View File

@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "debugger/debugger.h"
#include "machines/machinefactory.h"
#include "machines/machineproperties.h"
#include "ppcemu.h"
#include <cinttypes>
#include <cstring>
@ -36,6 +37,24 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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