Skip to content

Commit

Permalink
Update log system
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Dec 15, 2024
1 parent 0ab5e82 commit 3cf569b
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 84 deletions.
6 changes: 3 additions & 3 deletions platforms/audio-shared/sound_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ static void sdl_error(const char* str)
{
const char* sdl_str = SDL_GetError();
if (sdl_str && *sdl_str)
str = sdl_str;

Log("Sound Queue: %s", str);
Log("Sound Queue: %s - SDL Error: %s", str, sdl_str);
else
Log("Sound Queue: %s", str);
}

SoundQueue::SoundQueue()
Expand Down
2 changes: 1 addition & 1 deletion platforms/desktop-shared/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ else
endif

all: header $(TARGET)
@echo Build complete for $(PLATFORM) \($(BUILD_CONFIG)\)
@echo Build complete: $(TARGET_NAME) \($(BUILD_CONFIG)\) - $(GIT_VERSION) - $(PLATFORM)

$(TARGET): $(OBJECTS)
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
Expand Down
9 changes: 5 additions & 4 deletions platforms/desktop-shared/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ int application_init(const char* rom_file, const char* symbol_file)
{
Log("\n%s", GEARCOLECO_TITLE_ASCII);
Log("%s %s Desktop App", GEARCOLECO_TITLE, GEARCOLECO_VERSION);
Log("By Ignacio Sánchez (drhelius)");

config_init();
config_read();
Expand Down Expand Up @@ -148,6 +147,9 @@ static int sdl_init(void)
SDL_VERSION(&application_sdl_build_version);
SDL_GetVersion(&application_sdl_link_version);

Log("Using SDL %d.%d.%d (build)", application_sdl_build_version.major, application_sdl_build_version.minor, application_sdl_build_version.patch);
Log("Using SDL %d.%d.%d (link) ", application_sdl_link_version.major, application_sdl_link_version.minor, application_sdl_link_version.patch);

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
Expand All @@ -166,14 +168,13 @@ static int sdl_init(void)

if (application_gamepad_mappings > 0)
{
Log("Succesfuly loaded %d game controller mappings", application_gamepad_mappings);
Log("Succesfuly loaded %d game controller mappings from gamecontrollerdb.txt", application_gamepad_mappings);
}
else
{
Log("Game controller database not found!");
Log("ERROR: Game controller database not found (gamecontrollerdb.txt)!!");
}


int gamepads_found = 0;

for (int i = 0; i < SDL_NumJoysticks(); ++i)
Expand Down
20 changes: 10 additions & 10 deletions platforms/desktop-shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void config_read(void)
config_input[1].gamepad_asterisk = read_int("InputB", "GamepadAsterisk", SDL_CONTROLLER_BUTTON_START);
config_input[1].gamepad_hash = read_int("InputB", "GamepadHash", SDL_CONTROLLER_BUTTON_BACK);

Log("Settings loaded");
Debug("Settings loaded");
}

void config_write(void)
Expand Down Expand Up @@ -476,7 +476,7 @@ void config_write(void)

if (config_ini_file->write(config_ini_data, true))
{
Log("Settings saved");
Debug("Settings saved");
}
}

Expand Down Expand Up @@ -512,15 +512,15 @@ static int read_int(const char* group, const char* key, int default_value)
else
ret = std::stoi(value);

Log("Load setting: [%s][%s]=%d", group, key, ret);
Debug("Load setting: [%s][%s]=%d", group, key, ret);
return ret;
}

static void write_int(const char* group, const char* key, int integer)
{
std::string value = std::to_string(integer);
config_ini_data[group][key] = value;
Log("Save setting: [%s][%s]=%s", group, key, value.c_str());
Debug("Save setting: [%s][%s]=%s", group, key, value.c_str());
}

static float read_float(const char* group, const char* key, float default_value)
Expand All @@ -534,15 +534,15 @@ static float read_float(const char* group, const char* key, float default_value)
else
ret = strtof(value.c_str(), NULL);

Log("Load setting: [%s][%s]=%.2f", group, key, ret);
Debug("Load setting: [%s][%s]=%.2f", group, key, ret);
return ret;
}

static void write_float(const char* group, const char* key, float value)
{
std::string value_str = std::to_string(value);
config_ini_data[group][key] = value_str;
Log("Save setting: [%s][%s]=%s", group, key, value_str.c_str());
Debug("Save setting: [%s][%s]=%s", group, key, value_str.c_str());
}

static bool read_bool(const char* group, const char* key, bool default_value)
Expand All @@ -556,7 +556,7 @@ static bool read_bool(const char* group, const char* key, bool default_value)
else
std::istringstream(value) >> std::boolalpha >> ret;

Log("Load setting: [%s][%s]=%s", group, key, ret ? "true" : "false");
Debug("Load setting: [%s][%s]=%s", group, key, ret ? "true" : "false");
return ret;
}

Expand All @@ -567,18 +567,18 @@ static void write_bool(const char* group, const char* key, bool boolean)
std::string value;
value = converter.str();
config_ini_data[group][key] = value;
Log("Save setting: [%s][%s]=%s", group, key, value.c_str());
Debug("Save setting: [%s][%s]=%s", group, key, value.c_str());
}

static std::string read_string(const char* group, const char* key)
{
std::string ret = config_ini_data[group][key];
Log("Load setting: [%s][%s]=%s", group, key, ret.c_str());
Debug("Load setting: [%s][%s]=%s", group, key, ret.c_str());
return ret;
}

static void write_string(const char* group, const char* key, std::string value)
{
config_ini_data[group][key] = value;
Log("Save setting: [%s][%s]=%s", group, key, value.c_str());
Debug("Save setting: [%s][%s]=%s", group, key, value.c_str());
}
2 changes: 1 addition & 1 deletion platforms/desktop-shared/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void emu_save_screenshot(const char* file_path)

stbi_write_png(file_path, runtime.screen_width, runtime.screen_height, 3, emu_frame_buffer, runtime.screen_width * 3);

Log("Screenshot saved!");
Debug("Screenshot saved!");
}

static void save_ram(void)
Expand Down
2 changes: 1 addition & 1 deletion platforms/desktop-shared/gui_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ static void debug_window_vram_regs(void)

static void add_symbol(const char* line)
{
Log("Loading symbol %s", line);
Debug("Loading symbol %s", line);

DebugSymbol s;

Expand Down
2 changes: 1 addition & 1 deletion platforms/libretro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ CFLAGS += -DGG_DISABLE_DISASSEMBLER -Wall -D__LIBRETRO__ $(fpic)
CXXFLAGS += -DGG_DISABLE_DISASSEMBLER -Wall -D__LIBRETRO__ $(fpic)

all: $(TARGET)
@echo Build complete for $(platform)
@echo Build complete: $(TARGET_NAME) $(DEBUG) - $(GIT_VERSION) - $(platform)

$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
Expand Down
2 changes: 1 addition & 1 deletion src/AY8910.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void AY8910::Sync()

if (m_iBufferIndex >= GC_AUDIO_BUFFER_SIZE)
{
Log("SGM Audio buffer overflow");
Debug("SGM Audio buffer overflow");
m_iBufferIndex = 0;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/AY8910.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define AY8910_H

#include "definitions.h"
#include "log.h"

class AY8910
{
Expand Down
8 changes: 4 additions & 4 deletions src/Cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ bool Cartridge::LoadFromZipFile(const u8* buffer, int size)
return false;
}

Log("ZIP Content - Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u", file_stat.m_filename, file_stat.m_comment, (unsigned int) file_stat.m_uncomp_size, (unsigned int) file_stat.m_comp_size);
Debug("ZIP Content - Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u", file_stat.m_filename, file_stat.m_comment, (unsigned int) file_stat.m_uncomp_size, (unsigned int) file_stat.m_comp_size);

string fn((const char*) file_stat.m_filename);
transform(fn.begin(), fn.end(), fn.begin(), (int(*)(int)) tolower);
Expand Down Expand Up @@ -258,7 +258,7 @@ bool Cartridge::LoadFromFile(const char* path)

if (extension == "zip")
{
Log("Loading from ZIP...");
Debug("Loading from ZIP...");
m_bReady = LoadFromZipFile(reinterpret_cast<u8*> (memblock), size);
}
else
Expand All @@ -268,7 +268,7 @@ bool Cartridge::LoadFromFile(const char* path)

if (m_bReady)
{
Log("ROM loaded", path);
Debug("ROM loaded", path);
}
else
{
Expand Down Expand Up @@ -421,6 +421,6 @@ void Cartridge::GetInfoFromDB(u32 crc)

if (!found)
{
Log("ROM not found in database. CRC: %X", crc);
Debug("ROM not found in database. CRC: %X", crc);
}
}
1 change: 1 addition & 0 deletions src/Cartridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <list>
#include "definitions.h"
#include "log.h"

class Cartridge
{
Expand Down
4 changes: 2 additions & 2 deletions src/ColecoVisionIOPorts.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inline u8 ColecoVisionIOPorts::In(u8 port)
}
}

Log("--> ** Attempting to read from port $%X", port);
Debug("--> ** Attempting to read from port $%X", port);

return 0xFF;
}
Expand Down Expand Up @@ -141,7 +141,7 @@ inline void ColecoVisionIOPorts::Out(u8 port, u8 value)
}
else
{
Log("--> ** Output to port $%X: %X", port, value);
Debug("--> ** Output to port $%X: %X", port, value);
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/GearcolecoCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ GearcolecoCore::~GearcolecoCore()

void GearcolecoCore::Init(GC_Color_Format pixelFormat)
{
Log("--== %s %s by Ignacio Sanchez ==--", GEARCOLECO_TITLE, GEARCOLECO_VERSION);
Log("Loading %s core %s by Ignacio Sanchez", GEARCOLECO_TITLE, GEARCOLECO_VERSION);

m_pixelFormat = pixelFormat;

Expand Down Expand Up @@ -194,7 +194,7 @@ void GearcolecoCore::SaveDisassembledROM()
myfile.close();
}

Log("Disassembled ROM Saved");
Debug("Disassembled ROM Saved");
}
}

Expand Down Expand Up @@ -335,7 +335,7 @@ void GearcolecoCore::SaveState(int index)

SaveState(NULL, index);

Log("Save state %d created", index);
Debug("Save state %d created", index);
}

void GearcolecoCore::SaveState(const char* szPath, int index)
Expand Down Expand Up @@ -384,7 +384,7 @@ void GearcolecoCore::SaveState(const char* szPath, int index)

file.close();

Log("Save state created");
Debug("Save state created");
}

bool GearcolecoCore::SaveState(u8* buffer, size_t& size)
Expand Down Expand Up @@ -419,7 +419,7 @@ bool GearcolecoCore::SaveState(std::ostream& stream, size_t& size)
{
if (m_pCartridge->IsReady())
{
Log("Gathering save state data...");
Debug("Gathering save state data...");

m_pMemory->SaveState(stream);
m_pProcessor->SaveState(stream);
Expand All @@ -436,7 +436,7 @@ bool GearcolecoCore::SaveState(std::ostream& stream, size_t& size)
stream.write(reinterpret_cast<const char*> (&header_magic), sizeof(header_magic));
stream.write(reinterpret_cast<const char*> (&header_size), sizeof(header_size));

Log("Save state size: %d", static_cast<size_t>(stream.tellp()));
Debug("Save state size: %d", static_cast<size_t>(stream.tellp()));

return true;
}
Expand All @@ -452,7 +452,7 @@ void GearcolecoCore::LoadState(int index)

LoadState(NULL, index);

Log("State %d file loaded", index);
Debug("State %d file loaded", index);
}

void GearcolecoCore::LoadState(const char* szPath, int index)
Expand Down Expand Up @@ -499,7 +499,7 @@ void GearcolecoCore::LoadState(const char* szPath, int index)
{
if (LoadState(file))
{
Log("Save state loaded");
Debug("Save state loaded");
}
}
else
Expand All @@ -514,7 +514,7 @@ bool GearcolecoCore::LoadState(const u8* buffer, size_t size)
{
if (m_pCartridge->IsReady() && (size > 0) && IsValidPointer(buffer))
{
Log("Gathering load state data [%d bytes]...", size);
Debug("Gathering load state data [%d bytes]...", size);

using namespace std;

Expand Down Expand Up @@ -543,15 +543,15 @@ bool GearcolecoCore::LoadState(std::istream& stream)
size_t size = static_cast<size_t>(stream.tellg());
stream.seekg(0, ios::beg);

Log("Load state stream size: %d", size);
Debug("Load state stream size: %d", size);

stream.seekg(size - (2 * sizeof(u32)), ios::beg);
stream.read(reinterpret_cast<char*> (&header_magic), sizeof(header_magic));
stream.read(reinterpret_cast<char*> (&header_size), sizeof(header_size));
stream.seekg(0, ios::beg);

Log("Load state magic: 0x%08x", header_magic);
Log("Load state size: %d", header_size);
Debug("Load state magic: 0x%08x", header_magic);
Debug("Load state size: %d", header_size);

if ((header_size == size) && (header_magic == GC_SAVESTATE_MAGIC))
{
Expand Down
16 changes: 8 additions & 8 deletions src/Memory_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ inline u8 Memory::Read(u16 address)
{
if (address >= 0xFF80)
{
Log("--> ** EEPROM read: %X %X", address);
Debug("--> ** EEPROM read: %X %X", address);
}
return pRom[(address & 0x3FFF) + m_RomBankAddress];
}
Expand All @@ -86,7 +86,7 @@ inline u8 Memory::Read(u16 address)
{
if (address >= (romSize + 0x8000))
{
Log("--> ** Attempting to read from outer ROM: %X. ROM Size: %X", address, romSize);
Debug("--> ** Attempting to read from outer ROM: %X. ROM Size: %X", address, romSize);
return 0xFF;
}

Expand Down Expand Up @@ -131,7 +131,7 @@ inline void Memory::Write(u16 address, u8 value)
case 0xA000:
case 0xC000:
{
Log("--> ** Attempting to write on ROM: %X %X", address, value);
Debug("--> ** Attempting to write on ROM: %X %X", address, value);
break;
}
case 0xE000:
Expand All @@ -155,18 +155,18 @@ inline void Memory::Write(u16 address, u8 value)
}
#ifdef DEBUG_GEARCOLECO
if (address == 0xFFC0)
Log("--> ** EEPROM write SCL=0: %X %X", address, value);
Debug("--> ** EEPROM write SCL=0: %X %X", address, value);
if (address == 0xFFD0)
Log("--> ** EEPROM write SCL=1: %X %X", address, value);
Debug("--> ** EEPROM write SCL=1: %X %X", address, value);
if (address == 0xFFE0)
Log("--> ** EEPROM write SDA=0: %X %X", address, value);
Debug("--> ** EEPROM write SDA=0: %X %X", address, value);
if (address == 0xFFF0)
Log("--> ** EEPROM write SDA=1: %X %X", address, value);
Debug("--> ** EEPROM write SDA=1: %X %X", address, value);
#endif
}
else
{
Log("--> ** Attempting to write on ROM: %X %X", address, value);
Debug("--> ** Attempting to write on ROM: %X %X", address, value);
}
break;
}
Expand Down
Loading

0 comments on commit 3cf569b

Please sign in to comment.