gba_lcd.cpp, gf4500.cpp: Clean up error logging code and some macro usage

This commit is contained in:
AJR 2023-02-20 15:09:59 -05:00
parent ebfec312b0
commit 161475f27b
2 changed files with 15 additions and 46 deletions

View File

@ -15,7 +15,8 @@
#include "screen.h"
#include <cstdarg>
#define VERBOSE (0)
#include "logmacro.h"
namespace {
@ -65,21 +66,6 @@ namespace {
#define DISPSTAT_SET(val) HWLO_SET(0x004, val)
#define DISPSTAT_RESET(val) HWLO_RESET(0x004, val)
#define VERBOSE_LEVEL (0)
inline void ATTR_PRINTF(3,4) verboselog(device_t &device, int n_level, const char *s_fmt, ...)
{
if (VERBOSE_LEVEL >= n_level)
{
va_list v;
char buf[32768];
va_start(v, s_fmt);
vsprintf(buf, s_fmt, v);
va_end(v);
device.logerror("%08x: %s", device.machine().describe_context(), buf);
}
}
class object
{
public:
@ -132,7 +118,7 @@ public:
height = size_table[shape][size][1];
if (shape == 4)
verboselog(m_device, 0, "WARNING: attempted to draw an object of invalid shape\n");
m_device.logerror("WARNING: attempted to draw an object of invalid shape\n");
}
private:
@ -164,7 +150,7 @@ inline uint8_t gba_lcd_device::bg_video_mode()
if (mode > 5)
{
verboselog(*this, 0, "WARNING: attempted to set invalid BG video mode %d\n", mode);
logerror("WARNING: attempted to set invalid BG video mode %d\n", mode);
return 0;
}
@ -1583,10 +1569,10 @@ uint32_t gba_lcd_device::video_r(offs_t offset, uint32_t mem_mask)
throw emu_fatalerror("gba_lcd_device::video_r: Not enough register names in gba_lcd_device");
if (ACCESSING_BITS_0_15)
verboselog(*this, 2, "GBA I/O Read: %s = %04x\n", reg_names[offset * 2], retval & 0x0000ffff);
LOG("%s: GBA I/O Read: %s = %04x\n", machine().describe_context(), reg_names[offset * 2], retval & 0x0000ffff);
if (ACCESSING_BITS_16_31)
verboselog(*this, 2, "GBA I/O Read: %s = %04x\n", reg_names[offset * 2 + 1], (retval & 0xffff0000) >> 16);
LOG("%s: GBA I/O Read: %s = %04x\n", machine().describe_context(), reg_names[offset * 2 + 1], (retval & 0xffff0000) >> 16);
return retval;
}
@ -1599,10 +1585,10 @@ void gba_lcd_device::video_w(offs_t offset, uint32_t data, uint32_t mem_mask)
throw emu_fatalerror("gba_lcd_device::video_w: Not enough register names in gba_lcd_device");
if (ACCESSING_BITS_0_15)
verboselog(*this, 2, "GBA I/O Write: %s = %04x\n", reg_names[offset * 2], data & 0x0000ffff);
LOG("%s: GBA I/O Write: %s = %04x\n", machine().describe_context(), reg_names[offset * 2], data & 0x0000ffff);
if (ACCESSING_BITS_16_31)
verboselog(*this, 2, "GBA I/O Write: %s = %04x\n", reg_names[offset * 2 + 1], (data & 0xffff0000) >> 16);
LOG("%s: GBA I/O Write: %s = %04x\n", machine().describe_context(), reg_names[offset * 2 + 1], (data & 0xffff0000) >> 16);
switch (offset)
{

View File

@ -11,24 +11,8 @@
#include "emu.h"
#include "video/gf4500.h"
#include <cstdarg>
#define VERBOSE_LEVEL ( 0 )
static inline void ATTR_PRINTF(3,4) verboselog( device_t &device, int n_level, const char *s_fmt, ...)
{
if (VERBOSE_LEVEL >= n_level)
{
va_list v;
char buf[32768];
va_start(v, s_fmt);
vsprintf(buf, s_fmt, v);
va_end(v);
device.logerror("%s: %s", device.machine().describe_context(), buf);
}
}
#define BITS(x,m,n) (((x)>>(n))&(((uint32_t)1<<((m)-(n)+1))-1))
#define VERBOSE (0)
#include "logmacro.h"
#define GF4500_FRAMEBUF_OFFSET 0x20000
@ -82,10 +66,9 @@ void gf4500_device::vram_write16( uint16_t data )
static rgb_t gf4500_get_color_16( uint16_t data )
{
uint8_t r, g, b;
r = BITS(data, 15, 11) << 3;
g = BITS(data, 10, 5) << 2;
b = BITS(data, 4, 0) << 3;
uint8_t r = BIT(data, 11, 5) << 3;
uint8_t g = BIT(data, 5, 6) << 2;
uint8_t b = BIT(data, 0, 5) << 3;
return rgb_t(r, g, b);
}
@ -115,7 +98,7 @@ uint32_t gf4500_device::read(offs_t offset)
}
if ((offset < (GF4500_FRAMEBUF_OFFSET / 4)) || (offset >= ((GF4500_FRAMEBUF_OFFSET + (321 * 240 * 2)) / 4)))
{
verboselog( *this, 9, "(GFO) %08X -> %08X\n", 0x34000000 + (offset << 2), data);
LOG("%s: (GFO) %08X -> %08X\n", machine().describe_context(), 0x34000000 + (offset << 2), data);
}
return data;
}
@ -125,7 +108,7 @@ void gf4500_device::write(offs_t offset, uint32_t data, uint32_t mem_mask)
COMBINE_DATA(&m_data[offset]);
if ((offset < (GF4500_FRAMEBUF_OFFSET / 4)) || (offset >= ((GF4500_FRAMEBUF_OFFSET + (321 * 240 * 2)) / 4)))
{
verboselog( *this, 9, "(GFO) %08X <- %08X\n", 0x34000000 + (offset << 2), data);
LOG("%s: (GFO) %08X <- %08X\n", machine().describe_context(), 0x34000000 + (offset << 2), data);
}
switch (offset)
{