Started working on incorporating loguru

This commit is contained in:
dingusdev 2020-02-23 20:59:10 -07:00
parent 3ffa680f6d
commit e9a616ffeb
5 changed files with 3291 additions and 23 deletions

View File

@ -149,7 +149,6 @@ static void read_test_data()
int main() int main()
{ {
int i;
cout << "Running DingusPPC emulator tests..." << endl << endl; cout << "Running DingusPPC emulator tests..." << endl << endl;

View File

@ -10,6 +10,7 @@
Author: Max Poliakovski 2019 Author: Max Poliakovski 2019
*/ */
#include <thirdparty/loguru.cpp>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <cinttypes> #include <cinttypes>
@ -55,7 +56,7 @@ uint8_t ViaCuda::read(int reg)
{ {
uint8_t res; uint8_t res;
cout << "Read VIA reg " << hex << (uint32_t)reg << endl; LOG_F(INFO, "Read VIA reg %x \n", (uint32_t)reg);
res = this->via_regs[reg & 0xF]; res = this->via_regs[reg & 0xF];
@ -66,7 +67,7 @@ uint8_t ViaCuda::read(int reg)
break; break;
case VIA_A: case VIA_A:
case VIA_ANH: case VIA_ANH:
cout << "WARNING: read attempt from VIA Port A!" << endl; LOG_F(WARNING, "Attempted read from VIA Port A! \n");
break; break;
case VIA_IER: case VIA_IER:
res |= 0x80; /* bit 7 always reads as "1" */ res |= 0x80; /* bit 7 always reads as "1" */
@ -84,29 +85,28 @@ void ViaCuda::write(int reg, uint8_t value)
break; break;
case VIA_A: case VIA_A:
case VIA_ANH: case VIA_ANH:
cout << "WARNING: write attempt to VIA Port A!" << endl; LOG_F(WARNING, "Attempted read from VIA Port A! \n");
break; break;
case VIA_DIRB: case VIA_DIRB:
cout << "VIA_DIRB = " << hex << (uint32_t)value << endl; LOG_F(INFO, "VIA_DIRB = %x \n", (uint32_t)value);
this->via_regs[VIA_DIRB] = value; this->via_regs[VIA_DIRB] = value;
break; break;
case VIA_DIRA: case VIA_DIRA:
cout << "VIA_DIRA = " << hex << (uint32_t)value << endl; LOG_F(INFO, "VIA_DIRA = %x \n", (uint32_t)value);
this->via_regs[VIA_DIRA] = value; this->via_regs[VIA_DIRA] = value;
break; break;
case VIA_PCR: case VIA_PCR:
cout << "VIA_PCR = " << hex << (uint32_t)value << endl; LOG_F(INFO, "VIA_PCR = %x \n", (uint32_t)value);
this->via_regs[VIA_PCR] = value; this->via_regs[VIA_PCR] = value;
break; break;
case VIA_ACR: case VIA_ACR:
cout << "VIA_ACR = " << hex << (uint32_t)value << endl; LOG_F(INFO, "VIA_ACR = %x \n", (uint32_t)value);
this->via_regs[VIA_ACR] = value; this->via_regs[VIA_ACR] = value;
break; break;
case VIA_IER: case VIA_IER:
this->via_regs[VIA_IER] = (value & 0x80) ? value & 0x7F this->via_regs[VIA_IER] = (value & 0x80) ? value & 0x7F
: this->via_regs[VIA_IER] & ~value; : this->via_regs[VIA_IER] & ~value;
cout << "VIA_IER updated to " << hex << (uint32_t)this->via_regs[VIA_IER] LOG_F(INFO, "VIA_IER updated to %d \n", (uint32_t)this->via_regs[VIA_IER]);
<< endl;
print_enabled_ints(); print_enabled_ints();
break; break;
default: default:
@ -120,7 +120,7 @@ void ViaCuda::print_enabled_ints()
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
if (this->via_regs[VIA_IER] & (1 << i)) if (this->via_regs[VIA_IER] & (1 << i))
cout << "VIA " << via_int_src[i] << " interrupt enabled." << endl; LOG_F(INFO, "VIA %s interrupt enabled \n", via_int_src[i].c_str());
} }
} }
@ -137,7 +137,7 @@ inline void ViaCuda::assert_sr_int()
void ViaCuda::cuda_write(uint8_t new_state) void ViaCuda::cuda_write(uint8_t new_state)
{ {
if (!cuda_ready()) { if (!cuda_ready()) {
cout << "Cuda not ready!" << endl; LOG_F(ERROR, "Cuda not ready! \n");
return; return;
} }
@ -148,7 +148,7 @@ void ViaCuda::cuda_write(uint8_t new_state)
if (new_tip == this->old_tip && new_byteack == this->old_byteack) if (new_tip == this->old_tip && new_byteack == this->old_byteack)
return; return;
cout << "Cuda state changed!" << endl; LOG_F(INFO, "Cuda state changed! \n");
this->old_tip = new_tip; this->old_tip = new_tip;
this->old_byteack = new_byteack; this->old_byteack = new_byteack;
@ -168,7 +168,7 @@ void ViaCuda::cuda_write(uint8_t new_state)
this->in_count = 0; this->in_count = 0;
} else { } else {
cout << "Cuda: enter sync state" << endl; LOG_F(INFO, "Cuda: enter sync state \n");
this->via_regs[VIA_B] &= ~CUDA_TREQ; /* assert TREQ */ this->via_regs[VIA_B] &= ~CUDA_TREQ; /* assert TREQ */
this->treq = 0; this->treq = 0;
this->in_count = 0; this->in_count = 0;
@ -182,14 +182,14 @@ void ViaCuda::cuda_write(uint8_t new_state)
this->in_buf[this->in_count++] = this->via_regs[VIA_SR]; this->in_buf[this->in_count++] = this->via_regs[VIA_SR];
assert_sr_int(); /* tell the system we've read the data */ assert_sr_int(); /* tell the system we've read the data */
} else { } else {
cout << "Cuda input buffer exhausted!" << endl; LOG_F(WARNING, "Cuda input buffer exhausted! \n");
} }
} else { /* data transfer: Cuda --> Host */ } else { /* data transfer: Cuda --> Host */
if (this->out_count) { if (this->out_count) {
this->via_regs[VIA_SR] = this->out_buf[this->out_pos++]; this->via_regs[VIA_SR] = this->out_buf[this->out_pos++];
if (this->out_pos >= this->out_count) { if (this->out_pos >= this->out_count) {
cout << "Cuda: sending last byte" << endl; LOG_F(INFO, "Cuda: sending last byte \n");
this->out_count = 0; this->out_count = 0;
this->via_regs[VIA_B] |= CUDA_TREQ; /* negate TREQ */ this->via_regs[VIA_B] |= CUDA_TREQ; /* negate TREQ */
this->treq = 1; this->treq = 1;

View File

@ -8,6 +8,7 @@
//The main runfile - main.cpp //The main runfile - main.cpp
//This is where the magic begins //This is where the magic begins
#include <thirdparty/loguru.hpp>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <cstring> #include <cstring>
@ -59,18 +60,23 @@ GossamerID *machine_id;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
loguru::g_preamble_date = false;
loguru::g_preamble_time = false;
loguru::g_preamble_thread = false;
loguru::init(argc, argv);
LOG_SCOPE_FUNCTION(INFO);
uint32_t rom_filesize; uint32_t rom_filesize;
/* Init virtual CPU and request MPC750 CPU aka G3 */ /* Init virtual CPU and request MPC750 CPU aka G3 */
ppc_cpu_init(PPC_VER::MPC750); ppc_cpu_init(PPC_VER::MPC750);
uint32_t opcode_entered = 0; //used for testing opcodes in playground
std::cout << "DingusPPC - Prototype 5bf4 (7/14/2019) " << endl; std::cout << "DingusPPC - Prototype 5bf4 (7/14/2019) " << endl;
std::cout << "Written by divingkatae, (c) 2019. " << endl; std::cout << "Written by divingkatae, (c) 2019. " << endl;
std::cout << "This is not intended for general use. " << endl; std::cout << "This is not intended for general use. " << endl;
std::cout << "Use at your own discretion. " << endl; std::cout << "Use at your own discretion. " << endl;
LOG_F(INFO, "Checking for ROM file");
//Open the ROM File. //Open the ROM File.
ifstream romFile; ifstream romFile;
@ -87,7 +93,7 @@ int main(int argc, char **argv)
//Calculate and validate ROM file size. //Calculate and validate ROM file size.
romFile.seekg(0, romFile.end); romFile.seekg(0, romFile.end);
rom_filesize = (uint32_t) romFile.tellg(); rom_filesize = (uint32_t) romFile.tellg();
printf("Rom SIZE: %d \n", rom_filesize); LOG_F(INFO, "Rom SIZE: %d \n", rom_filesize);
romFile.seekg (0, romFile.beg); romFile.seekg (0, romFile.beg);
if (rom_filesize != 0x400000){ if (rom_filesize != 0x400000){
@ -118,7 +124,8 @@ int main(int argc, char **argv)
string redo_me = iter->first; string redo_me = iter->first;
if (string_test.compare(redo_me) == 0){ if (string_test.compare(redo_me) == 0){
cout << "The machine is identified as..." << iter->second << endl; const char* check_me = iter->second.c_str();
LOG_F(INFO, "The machine is identified as... %s \n", check_me);
romFile.seekg (0x0, ios::beg); romFile.seekg (0x0, ios::beg);
break; break;
} }
@ -129,11 +136,11 @@ int main(int argc, char **argv)
switch(rom_id) { switch(rom_id) {
case 0x476F7373: { case 0x476F7373: {
cout << "Initialize Gossamer hardware..." << endl; LOG_F(INFO, "Initialize Gossamer hardware... \n");
MPC106 *mpc106 = new MPC106(); MPC106 *mpc106 = new MPC106();
mem_ctrl_instance = mpc106; mem_ctrl_instance = mpc106;
if (!mem_ctrl_instance->add_rom_region(0xFFC00000, 0x400000)) { if (!mem_ctrl_instance->add_rom_region(0xFFC00000, 0x400000)) {
cout << "failure!\n" << endl; LOG_F(ERROR, "Failed to Gossamer hardware... \n");
delete(mem_ctrl_instance); delete(mem_ctrl_instance);
romFile.close(); romFile.close();
return 1; return 1;
@ -147,7 +154,7 @@ int main(int argc, char **argv)
} }
break; break;
default: default:
cout << "This machine not supported yet." << endl; LOG_F(INFO, "This machine not supported yet. \n");
return 1; return 1;
} }

1873
thirdparty/loguru.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1389
thirdparty/loguru.hpp vendored Normal file

File diff suppressed because it is too large Load Diff