dosbox-staging/include/logging.h

124 lines
3.3 KiB
C++
Raw Normal View History

/*
* Copyright (C) 2002-2021 The DOSBox Team
*
* 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 2 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef DOSBOX_LOGGING_H
#define DOSBOX_LOGGING_H
#include <cstdio>
2023-09-05 14:36:16 +10:00
#include <string>
#include "compiler.h"
#include "../src/libs/loguru/loguru.hpp"
2021-08-24 12:09:11 -05:00
enum LOG_TYPES {
LOG_ALL,
LOG_VGA, LOG_VGAGFX,LOG_VGAMISC,LOG_INT10,
LOG_SB,LOG_DMACONTROL,
LOG_FPU,LOG_CPU,LOG_PAGING,
LOG_FCB,LOG_FILES,LOG_IOCTL,LOG_EXEC,LOG_DOSMISC,
LOG_PIT,LOG_KEYBOARD,LOG_PIC,
LOG_MOUSE,LOG_BIOS,LOG_GUI,LOG_MISC,
LOG_IO,
LOG_PCI,
Import Jon Dennis's ReelMagic emulation package Notes from jrdennisoss as of (2022-11-06): I started this fork of DOSBox in order to run ReelMagic games. It would appear that no one else has done this, so I took this on as I really wanted to play the ReelMagic version of Return to Zork. The following people have made this project a reality: * Jon Dennis <jrdennisoss_at_gmail.com> * Chris Guthrie <csguthrieoss_at_gmail.com> * Joseph Whittaker <j.whittaker.us_at_ieee.org> It is also worth mentioning Dominic Szablewski's (https://phoboslab.org) awesome MPEG decoder library `PL_MPEG` was used for this, and of course this project is built on top of work the DOSBox Team created. The following ReelMagic games are known to work on this emulator with minimal issues: * Return to Zork * Lord of the Rings * The Horde * Entity * Man Enough * Dragon's Lair * Flash Traffic * Crime Patrol * Crime Patrol 2 - Drug Wars Note: Entity crashes when viewing a video message. This happens on both the emulator and on the real setup. * The emulator does not correctly implement MPEG DMA streaming. * MPEG video decode is only about 98% complete. There are a few glitches. * Need to revisit architecture and approach for mixing VGA and MPEG. * Need to re-base on to DOSBox SVN trunk. Runs just like normal DOSBox except that it supports ReelMagic MPEG games. There are some optional configuration parameters. See `Configuration` section under the `Changes to DOSBox` section below for more information on this. All that has been discovered about how the ReelMagic driver works and interacts with things is currently documented in the `RMDOS_API.md` file. Most ReelMagic MPEG file assets have been encoded in a non-standard way which prevents them from playing in a standard MPEG media player such as VLC. In order to get things properly working in DOSBox, I had to make a few changes to the MPEG decoder. More information on this can be found in the `NOTES_MPEG.md` file. Game bugs that are known to exist in both this emulator AND that also happen wich a real hardware setup are documented in the `KNOWN_GAME_BUGS.md` file. This helps with not spending too much time chasing phantom issues. Several modifications to DOSBox have been made to make this work. A `[reelmagic]` configuration section has been added. It is not mandatory to configure anything to have a working ReelMagic setup as the defaults will enable ReelMagic emulation. The parameters are: * `enabled` -- Enables/disables the ReelMagic emulator. By default this is `true` * `alwaysresident` -- This forces `FMPDRV.EXE` to always be loaded. By default this is `false` * `vgadup5hack` -- Duplicate every 5th VGA line to help give output a 4:3 ratio. By default this is `false` * `initialmagickey` -- Provides and alternate value for the initial global "magic key" value in hex. Defaults to 40044041. * `magicfhack` -- Use for MPEG video debugging purposes only. See `reelmagic_player.cpp` for what exactly this does to the MPEG decoder. * `a204debug` -- Controls FMPDRV.EXE function Ah subfunction 204h debug logging. Only applicable in "heavy debugging" build. * `a206debug` -- Controls FMPDRV.EXE function Ah subfunction 206h debug logging. Only applicable in "heavy debugging" build. For example: ``` [reelmagic] enabled=true alwaysresident=true vgadup5hack=false ``` The following existing DOSBox source code files have been modified for ReelMagic emulation functionality: * `include/logging.h` -- Added `REELMAGIC` logging type + quick fix for variable length logging args * `src/debug/debug_gui.cpp` -- Added `REELMAGIC` logging type. * `src/dosbox.cpp` -- ReelMagic init hook-in and config section. * `src/hardware/Makefile.am` -- Declared new ReelMagic *.cpp source code files The following files have been modified to include the ReelMagic override header to redirect all VGA output from DOSBox RENDER to ReelMagic: * `src/hardware/vga_dac.cpp` * `src/hardware/vga_draw.cpp` * `src/hardware/vga_other.cpp` The following new DOSBox source code files have been added for ReelMagic emulation functionality: * `include/reelmagic.h` -- Header file for all ReelMagic stuff * `include/vga_reelmagic_override.h` -- Header file used to redirect all VGA output from DOSBox RENDER to ReelMagic * `src/hardware/reelmagic_driver.cpp` -- Implements the Driver + Hardware Emulation * `src/hardware/reelmagic_pl_mpeg.cpp` -- Modified version of PHOBOSLAB's `PL_MPEG` library found here: `https://github.com/phoboslab/pl_mpeg` * `src/hardware/reelmagic_player.cpp` -- Implements MPEG Media Decoder/Player Functionality * `src/hardware/reelmagic_videomixer.cpp` -- Intercepts the VGA output and mixes in the decoded MPEG video. ReelMagic emulation software components are wired up as such: ``` |-----------------| |---------------| | PL_MPEG | | Existing | | Decoder Library | | DOSBox | |-----------------| | "Render" | ^ |---------------| | |-------------| ^ | Uses | | | Mixed VGA + MPEG | Outputs | DOSBox | | Output Goes Here |---------------| |-------------| Audio to | Mixer | |---------------| | | | | --------------->| | | | | Driver + | | MPEG | |-------------| | Video | | Hardware | <----------> | Player(s) | | Underlay | | Emulation | Controls | | -----------------------------------> | Mixer | | | |-------------| Outputs | | |---------------| Video to |---------------| ^ ^ | Can | Video Output | Use | Intercepted By |----------------| |---------------| | Emulated | | Existing | | DOS Programs | | DOSBox | |----------------| | VGA | | Emulation | |---------------| ``` See this guide: https://www.dosbox.com/wiki/Building_DOSBox_with_MinGW ``` sudo apt install build-essential autoconf automake-1.15 autotools-dev m4 ./autogen.sh ./configure make ``` ``` ./configure --enable-debug -- OR -- ./configure --enable-debug=heavy ``` Here are some useful online resources: Here is a handful of links that helped me get started on the ReelMagic side of things: * https://www.vogons.org/viewtopic.php?t=7364 * https://www.vogons.org/viewtopic.php?t=37363 * http://bitsavers.informatik.uni-stuttgart.de/pdf/c-cube/90-1450-101_CL450_MPEG_Video_Decoder_Users_Manual_1994.pdf * http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/rb-5094.htm * http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/rb-4251.htm This is the awesome MPEG decoder library used for this project. This guy gets it. * https://phoboslab.org/log/2019/06/pl-mpeg-single-file-library * https://github.com/phoboslab/pl_mpeg Imported-from: https://github.com/jrdennisoss/dosboxrm (as of commit ecde5ad / Jun 6, 2022)
2022-02-27 23:06:04 +00:00
LOG_REELMAGIC,
LOG_MAX
};
enum LOG_SEVERITIES {
LOG_NORMAL,
LOG_WARN,
LOG_ERROR
};
#if C_DEBUG
class LOG
{
LOG_TYPES d_type;
LOG_SEVERITIES d_severity;
public:
LOG (LOG_TYPES type , LOG_SEVERITIES severity):
d_type(type),
d_severity(severity)
{}
2023-09-05 14:36:16 +10:00
void operator()(const char* buf, ...)
GCC_ATTRIBUTE(__format__(__printf__, 2, 3)); //../src/debug/debug_gui.cpp
};
2023-09-05 14:36:16 +10:00
void DEBUG_ShowMsg(const char* format, ...)
GCC_ATTRIBUTE(__format__(__printf__, 1, 2));
#define LOG_MSG DEBUG_ShowMsg
2022-04-14 22:20:28 -07:00
#define LOG_INFO(...) LOG(LOG_ALL, LOG_NORMAL)(__VA_ARGS__)
#define LOG_WARNING(...) LOG(LOG_ALL, LOG_WARN)(__VA_ARGS__)
#define LOG_ERR(...) LOG(LOG_ALL, LOG_ERROR)(__VA_ARGS__)
#else // C_DEBUG
struct LOG
{
Import Jon Dennis's ReelMagic emulation package Notes from jrdennisoss as of (2022-11-06): I started this fork of DOSBox in order to run ReelMagic games. It would appear that no one else has done this, so I took this on as I really wanted to play the ReelMagic version of Return to Zork. The following people have made this project a reality: * Jon Dennis <jrdennisoss_at_gmail.com> * Chris Guthrie <csguthrieoss_at_gmail.com> * Joseph Whittaker <j.whittaker.us_at_ieee.org> It is also worth mentioning Dominic Szablewski's (https://phoboslab.org) awesome MPEG decoder library `PL_MPEG` was used for this, and of course this project is built on top of work the DOSBox Team created. The following ReelMagic games are known to work on this emulator with minimal issues: * Return to Zork * Lord of the Rings * The Horde * Entity * Man Enough * Dragon's Lair * Flash Traffic * Crime Patrol * Crime Patrol 2 - Drug Wars Note: Entity crashes when viewing a video message. This happens on both the emulator and on the real setup. * The emulator does not correctly implement MPEG DMA streaming. * MPEG video decode is only about 98% complete. There are a few glitches. * Need to revisit architecture and approach for mixing VGA and MPEG. * Need to re-base on to DOSBox SVN trunk. Runs just like normal DOSBox except that it supports ReelMagic MPEG games. There are some optional configuration parameters. See `Configuration` section under the `Changes to DOSBox` section below for more information on this. All that has been discovered about how the ReelMagic driver works and interacts with things is currently documented in the `RMDOS_API.md` file. Most ReelMagic MPEG file assets have been encoded in a non-standard way which prevents them from playing in a standard MPEG media player such as VLC. In order to get things properly working in DOSBox, I had to make a few changes to the MPEG decoder. More information on this can be found in the `NOTES_MPEG.md` file. Game bugs that are known to exist in both this emulator AND that also happen wich a real hardware setup are documented in the `KNOWN_GAME_BUGS.md` file. This helps with not spending too much time chasing phantom issues. Several modifications to DOSBox have been made to make this work. A `[reelmagic]` configuration section has been added. It is not mandatory to configure anything to have a working ReelMagic setup as the defaults will enable ReelMagic emulation. The parameters are: * `enabled` -- Enables/disables the ReelMagic emulator. By default this is `true` * `alwaysresident` -- This forces `FMPDRV.EXE` to always be loaded. By default this is `false` * `vgadup5hack` -- Duplicate every 5th VGA line to help give output a 4:3 ratio. By default this is `false` * `initialmagickey` -- Provides and alternate value for the initial global "magic key" value in hex. Defaults to 40044041. * `magicfhack` -- Use for MPEG video debugging purposes only. See `reelmagic_player.cpp` for what exactly this does to the MPEG decoder. * `a204debug` -- Controls FMPDRV.EXE function Ah subfunction 204h debug logging. Only applicable in "heavy debugging" build. * `a206debug` -- Controls FMPDRV.EXE function Ah subfunction 206h debug logging. Only applicable in "heavy debugging" build. For example: ``` [reelmagic] enabled=true alwaysresident=true vgadup5hack=false ``` The following existing DOSBox source code files have been modified for ReelMagic emulation functionality: * `include/logging.h` -- Added `REELMAGIC` logging type + quick fix for variable length logging args * `src/debug/debug_gui.cpp` -- Added `REELMAGIC` logging type. * `src/dosbox.cpp` -- ReelMagic init hook-in and config section. * `src/hardware/Makefile.am` -- Declared new ReelMagic *.cpp source code files The following files have been modified to include the ReelMagic override header to redirect all VGA output from DOSBox RENDER to ReelMagic: * `src/hardware/vga_dac.cpp` * `src/hardware/vga_draw.cpp` * `src/hardware/vga_other.cpp` The following new DOSBox source code files have been added for ReelMagic emulation functionality: * `include/reelmagic.h` -- Header file for all ReelMagic stuff * `include/vga_reelmagic_override.h` -- Header file used to redirect all VGA output from DOSBox RENDER to ReelMagic * `src/hardware/reelmagic_driver.cpp` -- Implements the Driver + Hardware Emulation * `src/hardware/reelmagic_pl_mpeg.cpp` -- Modified version of PHOBOSLAB's `PL_MPEG` library found here: `https://github.com/phoboslab/pl_mpeg` * `src/hardware/reelmagic_player.cpp` -- Implements MPEG Media Decoder/Player Functionality * `src/hardware/reelmagic_videomixer.cpp` -- Intercepts the VGA output and mixes in the decoded MPEG video. ReelMagic emulation software components are wired up as such: ``` |-----------------| |---------------| | PL_MPEG | | Existing | | Decoder Library | | DOSBox | |-----------------| | "Render" | ^ |---------------| | |-------------| ^ | Uses | | | Mixed VGA + MPEG | Outputs | DOSBox | | Output Goes Here |---------------| |-------------| Audio to | Mixer | |---------------| | | | | --------------->| | | | | Driver + | | MPEG | |-------------| | Video | | Hardware | <----------> | Player(s) | | Underlay | | Emulation | Controls | | -----------------------------------> | Mixer | | | |-------------| Outputs | | |---------------| Video to |---------------| ^ ^ | Can | Video Output | Use | Intercepted By |----------------| |---------------| | Emulated | | Existing | | DOS Programs | | DOSBox | |----------------| | VGA | | Emulation | |---------------| ``` See this guide: https://www.dosbox.com/wiki/Building_DOSBox_with_MinGW ``` sudo apt install build-essential autoconf automake-1.15 autotools-dev m4 ./autogen.sh ./configure make ``` ``` ./configure --enable-debug -- OR -- ./configure --enable-debug=heavy ``` Here are some useful online resources: Here is a handful of links that helped me get started on the ReelMagic side of things: * https://www.vogons.org/viewtopic.php?t=7364 * https://www.vogons.org/viewtopic.php?t=37363 * http://bitsavers.informatik.uni-stuttgart.de/pdf/c-cube/90-1450-101_CL450_MPEG_Video_Decoder_Users_Manual_1994.pdf * http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/rb-5094.htm * http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/rb-4251.htm This is the awesome MPEG decoder library used for this project. This guy gets it. * https://phoboslab.org/log/2019/06/pl-mpeg-single-file-library * https://github.com/phoboslab/pl_mpeg Imported-from: https://github.com/jrdennisoss/dosboxrm (as of commit ecde5ad / Jun 6, 2022)
2022-02-27 23:06:04 +00:00
inline LOG(LOG_TYPES, LOG_SEVERITIES){ }
2023-09-05 14:36:16 +10:00
inline void operator()(const char*, ...) {}
}; //add missing operators to here
Import Jon Dennis's ReelMagic emulation package Notes from jrdennisoss as of (2022-11-06): I started this fork of DOSBox in order to run ReelMagic games. It would appear that no one else has done this, so I took this on as I really wanted to play the ReelMagic version of Return to Zork. The following people have made this project a reality: * Jon Dennis <jrdennisoss_at_gmail.com> * Chris Guthrie <csguthrieoss_at_gmail.com> * Joseph Whittaker <j.whittaker.us_at_ieee.org> It is also worth mentioning Dominic Szablewski's (https://phoboslab.org) awesome MPEG decoder library `PL_MPEG` was used for this, and of course this project is built on top of work the DOSBox Team created. The following ReelMagic games are known to work on this emulator with minimal issues: * Return to Zork * Lord of the Rings * The Horde * Entity * Man Enough * Dragon's Lair * Flash Traffic * Crime Patrol * Crime Patrol 2 - Drug Wars Note: Entity crashes when viewing a video message. This happens on both the emulator and on the real setup. * The emulator does not correctly implement MPEG DMA streaming. * MPEG video decode is only about 98% complete. There are a few glitches. * Need to revisit architecture and approach for mixing VGA and MPEG. * Need to re-base on to DOSBox SVN trunk. Runs just like normal DOSBox except that it supports ReelMagic MPEG games. There are some optional configuration parameters. See `Configuration` section under the `Changes to DOSBox` section below for more information on this. All that has been discovered about how the ReelMagic driver works and interacts with things is currently documented in the `RMDOS_API.md` file. Most ReelMagic MPEG file assets have been encoded in a non-standard way which prevents them from playing in a standard MPEG media player such as VLC. In order to get things properly working in DOSBox, I had to make a few changes to the MPEG decoder. More information on this can be found in the `NOTES_MPEG.md` file. Game bugs that are known to exist in both this emulator AND that also happen wich a real hardware setup are documented in the `KNOWN_GAME_BUGS.md` file. This helps with not spending too much time chasing phantom issues. Several modifications to DOSBox have been made to make this work. A `[reelmagic]` configuration section has been added. It is not mandatory to configure anything to have a working ReelMagic setup as the defaults will enable ReelMagic emulation. The parameters are: * `enabled` -- Enables/disables the ReelMagic emulator. By default this is `true` * `alwaysresident` -- This forces `FMPDRV.EXE` to always be loaded. By default this is `false` * `vgadup5hack` -- Duplicate every 5th VGA line to help give output a 4:3 ratio. By default this is `false` * `initialmagickey` -- Provides and alternate value for the initial global "magic key" value in hex. Defaults to 40044041. * `magicfhack` -- Use for MPEG video debugging purposes only. See `reelmagic_player.cpp` for what exactly this does to the MPEG decoder. * `a204debug` -- Controls FMPDRV.EXE function Ah subfunction 204h debug logging. Only applicable in "heavy debugging" build. * `a206debug` -- Controls FMPDRV.EXE function Ah subfunction 206h debug logging. Only applicable in "heavy debugging" build. For example: ``` [reelmagic] enabled=true alwaysresident=true vgadup5hack=false ``` The following existing DOSBox source code files have been modified for ReelMagic emulation functionality: * `include/logging.h` -- Added `REELMAGIC` logging type + quick fix for variable length logging args * `src/debug/debug_gui.cpp` -- Added `REELMAGIC` logging type. * `src/dosbox.cpp` -- ReelMagic init hook-in and config section. * `src/hardware/Makefile.am` -- Declared new ReelMagic *.cpp source code files The following files have been modified to include the ReelMagic override header to redirect all VGA output from DOSBox RENDER to ReelMagic: * `src/hardware/vga_dac.cpp` * `src/hardware/vga_draw.cpp` * `src/hardware/vga_other.cpp` The following new DOSBox source code files have been added for ReelMagic emulation functionality: * `include/reelmagic.h` -- Header file for all ReelMagic stuff * `include/vga_reelmagic_override.h` -- Header file used to redirect all VGA output from DOSBox RENDER to ReelMagic * `src/hardware/reelmagic_driver.cpp` -- Implements the Driver + Hardware Emulation * `src/hardware/reelmagic_pl_mpeg.cpp` -- Modified version of PHOBOSLAB's `PL_MPEG` library found here: `https://github.com/phoboslab/pl_mpeg` * `src/hardware/reelmagic_player.cpp` -- Implements MPEG Media Decoder/Player Functionality * `src/hardware/reelmagic_videomixer.cpp` -- Intercepts the VGA output and mixes in the decoded MPEG video. ReelMagic emulation software components are wired up as such: ``` |-----------------| |---------------| | PL_MPEG | | Existing | | Decoder Library | | DOSBox | |-----------------| | "Render" | ^ |---------------| | |-------------| ^ | Uses | | | Mixed VGA + MPEG | Outputs | DOSBox | | Output Goes Here |---------------| |-------------| Audio to | Mixer | |---------------| | | | | --------------->| | | | | Driver + | | MPEG | |-------------| | Video | | Hardware | <----------> | Player(s) | | Underlay | | Emulation | Controls | | -----------------------------------> | Mixer | | | |-------------| Outputs | | |---------------| Video to |---------------| ^ ^ | Can | Video Output | Use | Intercepted By |----------------| |---------------| | Emulated | | Existing | | DOS Programs | | DOSBox | |----------------| | VGA | | Emulation | |---------------| ``` See this guide: https://www.dosbox.com/wiki/Building_DOSBox_with_MinGW ``` sudo apt install build-essential autoconf automake-1.15 autotools-dev m4 ./autogen.sh ./configure make ``` ``` ./configure --enable-debug -- OR -- ./configure --enable-debug=heavy ``` Here are some useful online resources: Here is a handful of links that helped me get started on the ReelMagic side of things: * https://www.vogons.org/viewtopic.php?t=7364 * https://www.vogons.org/viewtopic.php?t=37363 * http://bitsavers.informatik.uni-stuttgart.de/pdf/c-cube/90-1450-101_CL450_MPEG_Video_Decoder_Users_Manual_1994.pdf * http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/rb-5094.htm * http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/rb-4251.htm This is the awesome MPEG decoder library used for this project. This guy gets it. * https://phoboslab.org/log/2019/06/pl-mpeg-single-file-library * https://github.com/phoboslab/pl_mpeg Imported-from: https://github.com/jrdennisoss/dosboxrm (as of commit ecde5ad / Jun 6, 2022)
2022-02-27 23:06:04 +00:00
//try to avoid anything smaller than bit32...
2023-09-05 14:36:16 +10:00
void GFX_ShowMsg(const char* format, ...)
GCC_ATTRIBUTE(__format__(__printf__, 1, 2));
2021-08-24 12:09:11 -05:00
// Keep for compatibility
#define LOG_MSG(...) LOG_F(INFO, __VA_ARGS__)
2021-08-24 12:09:11 -05:00
#define LOG_INFO(...) LOG_F(INFO, __VA_ARGS__)
#define LOG_WARNING(...) LOG_F(WARNING, __VA_ARGS__)
#define LOG_ERR(...) LOG_F(ERROR, __VA_ARGS__)
2022-04-14 22:20:28 -07:00
#endif // C_DEBUG
#ifdef NDEBUG
// LOG_DEBUG exists only for messages useful during development, and not to
// be redirected into internal DOSBox debugger for DOS programs (C_DEBUG feature).
#define LOG_DEBUG(...)
2023-09-14 17:17:53 +10:00
#define LOG_TRACE(...)
#else
2023-09-05 14:36:16 +10:00
template <typename... Args>
void LOG_DEBUG(const std::string& format, const Args&... args) noexcept
2023-09-05 14:36:16 +10:00
{
const auto format_green = std::string(loguru::terminal_green()) +
loguru::terminal_bold() + format +
loguru::terminal_reset();
DLOG_F(INFO, format_green.c_str(), args...);
}
template <typename... Args>
void LOG_TRACE(const std::string& format, const Args&... args) noexcept
{
const auto format_purple = std::string(loguru::terminal_purple()) +
loguru::terminal_bold() + format +
loguru::terminal_reset();
DLOG_F(INFO, format_purple.c_str(), args...);
}
#endif // NDEBUG
#endif