summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/emu/cpu/drcbex64.c19
-rw-r--r--src/emu/cpu/drcbex86.c13
-rw-r--r--src/emu/cpu/drcuml.c6
-rw-r--r--src/emu/cpu/jaguar/jaguar.c16
-rw-r--r--src/emu/cpu/mips/mips3com.c5
-rw-r--r--src/emu/cpu/mips/psx.c17
-rw-r--r--src/emu/cpu/pdp1/pdp1.c3
-rw-r--r--src/emu/cpu/powerpc/drc_ops.c3
-rw-r--r--src/emu/cpu/powerpc/ppcdrc.c25
-rw-r--r--src/emu/cpu/rsp/rsp.c21
-rw-r--r--src/emu/cpu/sc61860/sc.h1
-rw-r--r--src/emu/machine/6840ptm.c7
-rw-r--r--src/emu/machine/idectrl.c7
-rw-r--r--src/emu/romload.c45
-rw-r--r--src/emu/sound/bsmt2000.c4
-rw-r--r--src/emu/sound/fmopl.c33
-rw-r--r--src/emu/sound/gaelco.c22
-rw-r--r--src/emu/sound/ics2115.c2
-rw-r--r--src/emu/sound/k053260.c4
-rw-r--r--src/emu/sound/qsound.c24
-rw-r--r--src/emu/sound/sn76477.c88
-rw-r--r--src/emu/sound/ym2151.c35
-rw-r--r--src/emu/sound/ym2413.c33
-rw-r--r--src/emu/sound/ymf262.c33
-rw-r--r--src/emu/video/resnet.c10
-rw-r--r--src/emu/video/v9938.c9
-rw-r--r--src/lib/util/chd.c4
-rw-r--r--src/mame/audio/blockade.c10
-rw-r--r--src/mame/drivers/atarigt.c40
-rw-r--r--src/mame/drivers/blockade.c14
-rw-r--r--src/mame/drivers/guab.c7
-rw-r--r--src/mame/drivers/rabbit.c5
-rw-r--r--src/mame/drivers/thunderj.c8
-rw-r--r--src/mame/machine/asic65.c8
-rw-r--r--src/mame/machine/cubocd32.c42
-rw-r--r--src/mame/machine/harddriv.c5
-rw-r--r--src/mame/machine/slapstic.c14
-rw-r--r--src/mame/video/jagobj.c6
-rw-r--r--src/mame/video/jaguar.c3
-rw-r--r--src/mame/video/midtunit.c6
-rw-r--r--src/mame/video/midyunit.c5
-rw-r--r--src/mame/video/n64.c14
-rw-r--r--src/mame/video/segas32.c19
-rw-r--r--src/mame/video/tx1.c5
-rw-r--r--src/osd/windows/sound.c22
-rw-r--r--src/osd/windows/winalloc.c16
-rw-r--r--src/osd/windows/window.c3
47 files changed, 280 insertions, 461 deletions
diff --git a/src/emu/cpu/drcbex64.c b/src/emu/cpu/drcbex64.c
index cdac02bf1fd..33597326dc0 100644
--- a/src/emu/cpu/drcbex64.c
+++ b/src/emu/cpu/drcbex64.c
@@ -312,6 +312,7 @@ static void drcbex64_get_info(drcbe_state *state, drcbe_info *info);
/* private helper functions */
static void fixup_label(void *parameter, drccodeptr labelcodeptr);
+static void debug_log_hashjmp(int mode, offs_t pc);
@@ -714,9 +715,8 @@ static drcbe_state *drcbex64_alloc(drcuml_state *drcuml, drccache *cache, UINT32
/* get pointers to C functions we need to call */
drcbe->debug_cpu_instruction_hook = (x86code *)debug_cpu_instruction_hook;
-#if LOG_HASHJMPS
- drcbe->debug_log_hashjmp = (x86code *)debug_log_hashjmp;
-#endif
+ if (LOG_HASHJMPS)
+ drcbe->debug_log_hashjmp = (x86code *)debug_log_hashjmp;
drcbe->drcmap_get_value = (x86code *)drcmap_get_value;
/* allocate hash tables */
@@ -2951,12 +2951,10 @@ static void fixup_exception(drccodeptr *codeptr, void *param1, void *param2, voi
logging of hashjmps
-------------------------------------------------*/
-#if LOG_HASHJMPS
static void debug_log_hashjmp(int mode, offs_t pc)
{
printf("mode=%d PC=%08X\n", mode, pc);
}
-#endif
@@ -3155,11 +3153,12 @@ static x86code *op_hashjmp(drcbe_state *drcbe, x86code *dst, const drcuml_instru
/* normalize parameters */
param_normalize_3(drcbe, inst, &modep, PTYPE_MRI, &pcp, PTYPE_MRI, &exp, PTYPE_M);
-#if LOG_HASHJMPS
- emit_mov_r32_p32(drcbe, &dst, REG_PARAM1, &pcp);
- emit_mov_r32_p32(drcbe, &dst, REG_PARAM2, &modep);
- emit_smart_call_m64(drcbe, &dst, &drcbe->debug_log_hashjmp);
-#endif
+ if (LOG_HASHJMPS)
+ {
+ emit_mov_r32_p32(drcbe, &dst, REG_PARAM1, &pcp);
+ emit_mov_r32_p32(drcbe, &dst, REG_PARAM2, &modep);
+ emit_smart_call_m64(drcbe, &dst, &drcbe->debug_log_hashjmp);
+ }
/* load the stack base one word early so we end up at the right spot after our call below */
emit_mov_r64_m64(&dst, REG_RSP, MABS(drcbe, &drcbe->hashstacksave)); // mov rsp,[hashstacksave]
diff --git a/src/emu/cpu/drcbex86.c b/src/emu/cpu/drcbex86.c
index 89abfa4fa16..c6d790fa834 100644
--- a/src/emu/cpu/drcbex86.c
+++ b/src/emu/cpu/drcbex86.c
@@ -3077,12 +3077,10 @@ static void fixup_exception(drccodeptr *codeptr, void *param1, void *param2, voi
logging of hashjmps
-------------------------------------------------*/
-#if LOG_HASHJMPS
static void debug_log_hashjmp(int mode, offs_t pc)
{
printf("mode=%d PC=%08X\n", mode, pc);
}
-#endif
@@ -3280,11 +3278,12 @@ static x86code *op_hashjmp(drcbe_state *drcbe, x86code *dst, const drcuml_instru
/* normalize parameters */
param_normalize_3(drcbe, inst, &modep, PTYPE_MRI, &pcp, PTYPE_MRI, &exp, PTYPE_M);
-#if LOG_HASHJMPS
- emit_mov_m32_p32(drcbe, &dst, MBD(REG_ESP, 4), &pcp);
- emit_mov_m32_p32(drcbe, &dst, MBD(REG_ESP, 0), &modep);
- emit_call(&dst, (x86code *)debug_log_hashjmp);
-#endif
+ if (LOG_HASHJMPS)
+ {
+ emit_mov_m32_p32(drcbe, &dst, MBD(REG_ESP, 4), &pcp);
+ emit_mov_m32_p32(drcbe, &dst, MBD(REG_ESP, 0), &modep);
+ emit_call(&dst, (x86code *)debug_log_hashjmp);
+ }
/* load the stack base one word early so we end up at the right spot after our call below */
emit_mov_r32_m32(&dst, REG_ESP, MABS(&drcbe->hashstacksave)); // mov esp,[hashstacksave]
diff --git a/src/emu/cpu/drcuml.c b/src/emu/cpu/drcuml.c
index a3e46bfbcf9..1a85d93f0e9 100644
--- a/src/emu/cpu/drcuml.c
+++ b/src/emu/cpu/drcuml.c
@@ -1369,9 +1369,7 @@ static void simplify_instruction_with_no_flags(drcuml_block *block, drcuml_instr
static const UINT64 instsizemask[] = { 0, 0, 0, 0, 0xffffffff, 0, 0, 0, U64(0xffffffffffffffff) };
static const UINT64 paramsizemask[] = { 0xff, 0xffff, 0xffffffff, U64(0xffffffffffffffff) };
drcuml_opcode origop = inst->opcode;
-#if LOG_SIMPLIFICATIONS
drcuml_instruction orig = *inst;
-#endif
switch (inst->opcode)
{
@@ -1688,15 +1686,13 @@ static void simplify_instruction_with_no_flags(drcuml_block *block, drcuml_instr
break;
}
-#if LOG_SIMPLIFICATIONS
- if (memcmp(&orig, inst, sizeof(orig)) != 0)
+ if (LOG_SIMPLIFICATIONS && memcmp(&orig, inst, sizeof(orig)) != 0)
{
char disasm1[256], disasm2[256];
drcuml_disasm(&orig, disasm1, block->drcuml);
drcuml_disasm(inst, disasm2, block->drcuml);
mame_printf_debug("Simplified: %-50.50s -> %s\n", disasm1, disasm2);
}
-#endif
/* if the opcode changed, validate and reoptimize */
if (inst->opcode != origop)
diff --git a/src/emu/cpu/jaguar/jaguar.c b/src/emu/cpu/jaguar/jaguar.c
index 58618215a83..4cbe0f7c16b 100644
--- a/src/emu/cpu/jaguar/jaguar.c
+++ b/src/emu/cpu/jaguar/jaguar.c
@@ -1295,9 +1295,7 @@ UINT32 jaguargpu_ctrl_r(int cpunum, offs_t offset)
{
UINT32 result;
-#if LOG_GPU_IO
- logerror("%08X/%d:GPU read register @ F021%02X\n", activecpu_get_previouspc(), cpu_getactivecpu(), offset * 4);
-#endif
+ if (LOG_GPU_IO) logerror("%08X/%d:GPU read register @ F021%02X\n", activecpu_get_previouspc(), cpu_getactivecpu(), offset * 4);
/* switch to the target context */
cpuintrf_push_context(cpunum);
@@ -1312,10 +1310,8 @@ void jaguargpu_ctrl_w(int cpunum, offs_t offset, UINT32 data, UINT32 mem_mask)
{
UINT32 oldval, newval;
-#if LOG_GPU_IO
- if (offset != G_HIDATA)
+ if (LOG_GPU_IO && offset != G_HIDATA)
logerror("%08X/%d:GPU write register @ F021%02X = %08X\n", activecpu_get_previouspc(), cpu_getactivecpu(), offset * 4, data);
-#endif
/* switch to the target context */
cpuintrf_push_context(cpunum);
@@ -1408,10 +1404,8 @@ UINT32 jaguardsp_ctrl_r(int cpunum, offs_t offset)
{
UINT32 result;
-#if LOG_DSP_IO
- if (offset != D_FLAGS)
+ if (LOG_DSP_IO && offset != D_FLAGS)
logerror("%08X/%d:DSP read register @ F1A1%02X\n", activecpu_get_previouspc(), cpu_getactivecpu(), offset * 4);
-#endif
/* switch to the target context */
cpuintrf_push_context(cpunum);
@@ -1426,10 +1420,8 @@ void jaguardsp_ctrl_w(int cpunum, offs_t offset, UINT32 data, UINT32 mem_mask)
{
UINT32 oldval, newval;
-#if LOG_DSP_IO
- if (offset != D_FLAGS)
+ if (LOG_DSP_IO && offset != D_FLAGS)
logerror("%08X/%d:DSP write register @ F1A1%02X = %08X\n", activecpu_get_previouspc(), cpu_getactivecpu(), offset * 4, data);
-#endif
/* switch to the target context */
cpuintrf_push_context(cpunum);
diff --git a/src/emu/cpu/mips/mips3com.c b/src/emu/cpu/mips/mips3com.c
index edd7248400a..df3caf015e6 100644
--- a/src/emu/cpu/mips/mips3com.c
+++ b/src/emu/cpu/mips/mips3com.c
@@ -886,7 +886,8 @@ static void tlb_write_common(mips3_state *mips, int tlbindex)
static void tlb_entry_log_half(mips3_tlb_entry *entry, int tlbindex, int which)
{
-#if PRINTF_TLB
+if (PRINTF_TLB)
+{
UINT64 hi = entry->entry_hi;
UINT64 lo = entry->entry_lo[which];
UINT32 vpn = (((hi >> 13) & 0x07ffffff) << 1);
@@ -903,5 +904,5 @@ static void tlb_entry_log_half(mips3_tlb_entry *entry, int tlbindex, int which)
printf("index=%08X pagesize=%08X vaddr=%08X%08X paddr=%08X%08X asid=%02X r=%X c=%X dvg=%c%c%c\n",
tlbindex, pagesize, (UINT32)(vaddr >> 32), (UINT32)vaddr, (UINT32)(paddr >> 32), (UINT32)paddr,
asid, r, c, (lo & 4) ? 'd' : '.', (lo & 2) ? 'v' : '.', (lo & 1) ? 'g' : '.');
-#endif
+}
}
diff --git a/src/emu/cpu/mips/psx.c b/src/emu/cpu/mips/psx.c
index 2b2e1bacde2..8250d7f2074 100644
--- a/src/emu/cpu/mips/psx.c
+++ b/src/emu/cpu/mips/psx.c
@@ -260,8 +260,6 @@ static void mips_stop( void )
debugger_instruction_hook(Machine, mipscpu.pc );
}
-#if LOG_BIOSCALL
-
static const struct
{
int address;
@@ -938,8 +936,6 @@ static void log_syscall( void )
logerror( "%08x: syscall %s\n", (unsigned int)activecpu_get_reg( MIPS_R31 ) - 8, buf );
}
-#endif
-
static UINT32 mips_cache_readword( UINT32 offset )
{
UINT32 data = 0;
@@ -1450,12 +1446,10 @@ static void mips_common_exception( int exception, UINT32 romOffset, UINT32 ramOf
mips_set_cp0r( CP0_EPC, mipscpu.pc );
}
-#if LOG_BIOSCALL
- if( exception != EXC_INT )
+ if( LOG_BIOSCALL && exception != EXC_INT )
{
logerror( "%08x: Exception %d\n", mipscpu.pc, exception );
}
-#endif
mipscpu.delayr = 0;
mipscpu.delayv = 0;
@@ -1799,10 +1793,7 @@ static int mips_execute( int cycles )
mips_ICount = cycles;
do
{
-#if LOG_BIOSCALL
- log_bioscall();
-#endif
-
+ if (LOG_BIOSCALL) log_bioscall();
debugger_instruction_hook(Machine, mipscpu.pc );
mipscpu.op = cpu_readop32( mipscpu.pc );
@@ -1848,9 +1839,7 @@ static int mips_execute( int cycles )
break;
case FUNCT_SYSCALL:
-#if LOG_BIOSCALL
- log_syscall();
-#endif
+ if (LOG_BIOSCALL) log_syscall();
mips_exception( EXC_SYS );
break;
diff --git a/src/emu/cpu/pdp1/pdp1.c b/src/emu/cpu/pdp1/pdp1.c
index 3c397945a1c..e9e0e5d1979 100644
--- a/src/emu/cpu/pdp1/pdp1.c
+++ b/src/emu/cpu/pdp1/pdp1.c
@@ -340,10 +340,7 @@
#define LOG 0
#define LOG_EXTRA 0
-
-#ifndef LOG_IOT_EXTRA
#define LOG_IOT_EXTRA 0
-#endif
static void execute_instruction(void);
diff --git a/src/emu/cpu/powerpc/drc_ops.c b/src/emu/cpu/powerpc/drc_ops.c
index 8ca085a7b23..058b5f56811 100644
--- a/src/emu/cpu/powerpc/drc_ops.c
+++ b/src/emu/cpu/powerpc/drc_ops.c
@@ -185,13 +185,12 @@ static void ppcdrc_recompile(drc_core *drc)
/* end the sequence */
drc_end_sequence(drc);
-#if LOG_CODE
+if (0)
{
char label[40];
sprintf(label, "Code @ %08X", ppc.pc);
code_log(label, start, drc->cache_top);
}
-#endif
}
static void update_counters(drc_core *drc)
diff --git a/src/emu/cpu/powerpc/ppcdrc.c b/src/emu/cpu/powerpc/ppcdrc.c
index 4e20a751a67..2d68feb2baa 100644
--- a/src/emu/cpu/powerpc/ppcdrc.c
+++ b/src/emu/cpu/powerpc/ppcdrc.c
@@ -3966,11 +3966,12 @@ static int generate_instruction_3f(drcuml_block *block, compiler_state *compiler
static void log_add_disasm_comment(drcuml_block *block, UINT32 pc, UINT32 op)
{
-#if (LOG_UML)
char buffer[100];
- ppc_dasm_one(buffer, pc, op);
- UML_COMMENT(block, "%08X: %s", pc, buffer); // comment
-#endif
+ if (LOG_UML)
+ {
+ ppc_dasm_one(buffer, pc, op);
+ UML_COMMENT(block, "%08X: %s", pc, buffer); // comment
+ }
}
@@ -4149,14 +4150,16 @@ static void log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desclist, i
char buffer[100];
/* disassemle the current instruction and output it to the log */
-#if (LOG_UML || LOG_NATIVE)
- if (desclist->flags & OPFLAG_VIRTUAL_NOOP)
- strcpy(buffer, "<virtual nop>");
+ if (LOG_UML || LOG_NATIVE)
+ {
+ if (desclist->flags & OPFLAG_VIRTUAL_NOOP)
+ strcpy(buffer, "<virtual nop>");
+ else
+ ppc_dasm_one(buffer, desclist->pc, *desclist->opptr.l);
+ }
else
- ppc_dasm_one(buffer, desclist->pc, *desclist->opptr.l);
-#else
- strcpy(buffer, "???");
-#endif
+ strcpy(buffer, "???");
+
drcuml_log_printf(drcuml, "%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), buffer);
/* output register states */
diff --git a/src/emu/cpu/rsp/rsp.c b/src/emu/cpu/rsp/rsp.c
index 718153c852f..68b8655ebd9 100644
--- a/src/emu/cpu/rsp/rsp.c
+++ b/src/emu/cpu/rsp/rsp.c
@@ -26,9 +26,7 @@
extern offs_t rsp_dasm_one(char *buffer, offs_t pc, UINT32 op);
-#if LOG_INSTRUCTION_EXECUTION
static FILE *exec_output;
-#endif
static rsp_config *config;
@@ -350,9 +348,8 @@ static void rsp_init(int index, int clock, const void *_config, int (*irqcallbac
int accumIdx;
config = (rsp_config *)_config;
-#if LOG_INSTRUCTION_EXECUTION
- exec_output = fopen("rsp_execute.txt", "wt");
-#endif
+ if (LOG_INSTRUCTION_EXECUTION)
+ exec_output = fopen("rsp_execute.txt", "wt");
rsp.irq_callback = irqcallback;
@@ -427,9 +424,9 @@ static void rsp_exit(void)
}
#endif
-#if LOG_INSTRUCTION_EXECUTION
- fclose(exec_output);
-#endif
+ if (exec_output)
+ fclose(exec_output);
+ exec_output = NULL;
}
static void rsp_reset(void)
@@ -2629,9 +2626,8 @@ static int rsp_execute(int cycles)
(config->sp_set_status)(0x3);
rsp_icount = MIN(rsp_icount, 1);
-#if LOG_INSTRUCTION_EXECUTION
- fprintf(exec_output, "\n---------- break ----------\n\n");
-#endif
+ if (LOG_INSTRUCTION_EXECUTION) fprintf(exec_output, "\n---------- break ----------\n\n");
+
break;
}
case 0x20: /* ADD */ if (RDREG) RDVAL = (INT32)(RSVAL + RTVAL); break;
@@ -2783,7 +2779,7 @@ static int rsp_execute(int cycles)
}
}
-#if LOG_INSTRUCTION_EXECUTION
+ if (LOG_INSTRUCTION_EXECUTION)
{
int i, l;
static UINT32 prev_regs[32];
@@ -2827,7 +2823,6 @@ static int rsp_execute(int cycles)
fprintf(exec_output, "\n");
}
-#endif
--rsp_icount;
diff --git a/src/emu/cpu/sc61860/sc.h b/src/emu/cpu/sc61860/sc.h
index 8f7d843a365..11e70cff8b4 100644
--- a/src/emu/cpu/sc61860/sc.h
+++ b/src/emu/cpu/sc61860/sc.h
@@ -31,4 +31,3 @@ enum {
};
#define PEEK_OP(pc) cpu_readop(pc)
-#define PEEK_NIBBLE(adr) cpu_readmem_16(adr)
diff --git a/src/emu/machine/6840ptm.c b/src/emu/machine/6840ptm.c
index cef706edfb8..4a4515e8533 100644
--- a/src/emu/machine/6840ptm.c
+++ b/src/emu/machine/6840ptm.c
@@ -39,12 +39,7 @@
// Defines /////////////////////////////////////////////////////////////
#define PTMVERBOSE 0
-
-#if PTMVERBOSE
- #define PLOG(x) logerror x;
-#else
- #define PLOG(x)
-#endif
+#define PLOG(x) do { if (PTMVERBOSE) logerror x; } while (0)
enum
{
diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c
index 785f4b323e3..9583f34dc25 100644
--- a/src/emu/machine/idectrl.c
+++ b/src/emu/machine/idectrl.c
@@ -1345,7 +1345,7 @@ static void ide_controller_write(const device_config *device, offs_t offset, int
LOGPRINT(("IDE Unlocked master password\n"));
ide->master_password_enable = 0;
}
-#if PRINTF_IDE_PASSWORD
+ if (PRINTF_IDE_PASSWORD)
{
int i;
@@ -1359,7 +1359,6 @@ static void ide_controller_write(const device_config *device, offs_t offset, int
}
mame_printf_debug("\n");
}
-#endif
/* clear the busy adn error flags */
ide->status &= ~IDE_STATUS_ERROR;
@@ -1696,9 +1695,7 @@ static DEVICE_START( ide_controller )
ide->num_cylinders = hdinfo->cylinders;
ide->num_sectors = hdinfo->sectors;
ide->num_heads = hdinfo->heads;
-#if PRINTF_IDE_COMMANDS
- mame_printf_debug("CHS: %d %d %d\n", ide->num_cylinders, ide->num_heads, ide->num_sectors);
-#endif
+ if (PRINTF_IDE_COMMANDS) mame_printf_debug("CHS: %d %d %d\n", ide->num_cylinders, ide->num_heads, ide->num_sectors);
}
}
diff --git a/src/emu/romload.c b/src/emu/romload.c
index 53016deacd4..bf31b7d97cb 100644
--- a/src/emu/romload.c
+++ b/src/emu/romload.c
@@ -19,7 +19,8 @@
#include "deprecat.h"
-//#define LOG_LOAD
+#define LOG_LOAD 0
+#define LOG(x) do { if (LOG_LOAD) debugload x; } while(0)
@@ -163,7 +164,6 @@ const rom_entry *rom_next_chunk(const rom_entry *romp)
static void CLIB_DECL ATTR_PRINTF(1,2) debugload(const char *string, ...)
{
-#ifdef LOG_LOAD
static int opened;
va_list arg;
FILE *f;
@@ -176,7 +176,6 @@ static void CLIB_DECL ATTR_PRINTF(1,2) debugload(const char *string, ...)
va_end(arg);
fclose(f);
}
-#endif
}
@@ -221,7 +220,7 @@ static int determine_bios_rom(rom_load_data *romdata, const rom_entry *romp)
bios_no = 1;
}
- debugload("Using System BIOS: %d\n", bios_no);
+ LOG(("Using System BIOS: %d\n", bios_no));
return bios_no;
}
@@ -457,12 +456,12 @@ static void region_post_process(running_machine *machine, rom_load_data *romdata
UINT8 *base;
int i, j;
- debugload("+ datawidth=%d little=%d\n", datawidth, littleendian);
+ LOG(("+ datawidth=%d little=%d\n", datawidth, littleendian));
/* if the region is inverted, do that now */
if (regionflags & ROMREGION_INVERTMASK)
{
- debugload("+ Inverting region\n");
+ LOG(("+ Inverting region\n"));
for (i = 0, base = regionbase; i < regionlength; i++)
*base++ ^= 0xff;
}
@@ -474,7 +473,7 @@ static void region_post_process(running_machine *machine, rom_load_data *romdata
if (datawidth > 1 && littleendian)
#endif
{
- debugload("+ Byte swapping region\n");
+ LOG(("+ Byte swapping region\n"));
for (i = 0, base = regionbase; i < regionlength; i += datawidth)
{
UINT8 temp[8];
@@ -562,7 +561,7 @@ static int read_rom_data(rom_load_data *romdata, const rom_entry *romp)
UINT8 *base = romdata->regionbase + ROM_GETOFFSET(romp);
int i;
- debugload("Loading ROM data: offs=%X len=%X mask=%02X group=%d skip=%d reverse=%d\n", ROM_GETOFFSET(romp), numbytes, datamask, groupsize, skip, reversed);
+ LOG(("Loading ROM data: offs=%X len=%X mask=%02X group=%d skip=%d reverse=%d\n", ROM_GETOFFSET(romp), numbytes, datamask, groupsize, skip, reversed));
/* make sure the length was an even multiple of the group size */
if (numbytes % groupsize != 0)
@@ -589,12 +588,12 @@ static int read_rom_data(rom_load_data *romdata, const rom_entry *romp)
UINT8 *bufptr = romdata->tempbuf;
/* read as much as we can */
- debugload(" Reading %X bytes into buffer\n", bytesleft);
+ LOG((" Reading %X bytes into buffer\n", bytesleft));
if (rom_fread(romdata, romdata->tempbuf, bytesleft) != bytesleft)
return 0;
numbytes -= bytesleft;
- debugload(" Copying to %p\n", base);
+ LOG((" Copying to %p\n", base));
/* unmasked cases */
if (datamask == 0xff)
@@ -650,7 +649,7 @@ static int read_rom_data(rom_load_data *romdata, const rom_entry *romp)
}
}
}
- debugload(" All done\n");
+ LOG((" All done\n"));
return ROM_GETLENGTH(romp);
}
@@ -753,7 +752,7 @@ static void process_rom_entries(rom_load_data *romdata, const rom_entry *romp)
int explength = 0;
/* open the file */
- debugload("Opening ROM file: %s\n", ROM_GETNAME(romp));
+ LOG(("Opening ROM file: %s\n", ROM_GETNAME(romp)));
if (!open_rom_file(romdata, romp))
handle_missing_file(romdata, romp);
@@ -783,9 +782,9 @@ static void process_rom_entries(rom_load_data *romdata, const rom_entry *romp)
/* if this was the first use of this file, verify the length and CRC */
if (baserom)
{
- debugload("Verifying length (%X) and checksums\n", explength);
+ LOG(("Verifying length (%X) and checksums\n", explength));
verify_length_and_hash(romdata, ROM_GETNAME(baserom), explength, ROM_GETHASHDATA(baserom));
- debugload("Verify finished\n");
+ LOG(("Verify finished\n"));
}
/* reseek to the start and clear the baserom so we don't reverify */
@@ -799,7 +798,7 @@ static void process_rom_entries(rom_load_data *romdata, const rom_entry *romp)
/* close the file */
if (romdata->file)
{
- debugload("Closing ROM file\n");
+ LOG(("Closing ROM file\n"));
mame_fclose(romdata->file);
romdata->file = NULL;
}
@@ -919,12 +918,12 @@ static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, c
*diff_chd = NULL;
/* try to open the diff */
- debugload("Opening differencing image file: %s\n", astring_c(fname));
+ LOG(("Opening differencing image file: %s\n", astring_c(fname)));
filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE, diff_file);
if (filerr != FILERR_NONE)
{
/* didn't work; try creating it instead */
- debugload("Creating differencing image: %s\n", astring_c(fname));
+ LOG(("Creating differencing image: %s\n", astring_c(fname)));
filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, diff_file);
if (filerr != FILERR_NONE)
{
@@ -938,7 +937,7 @@ static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, c
goto done;
}
- debugload("Opening differencing image file: %s\n", astring_c(fname));
+ LOG(("Opening differencing image file: %s\n", astring_c(fname)));
err = chd_open_file(mame_core_file(*diff_file), CHD_OPEN_READWRITE, source, diff_chd);
if (err != CHDERR_NONE)
goto done;
@@ -977,7 +976,7 @@ static void process_disk_entries(rom_load_data *romdata, const rom_entry *romp)
filename = astring_assemble_2(astring_alloc(), ROM_GETNAME(romp), ".chd");
/* first open the source drive */
- debugload("Opening disk image: %s\n", astring_c(filename));
+ LOG(("Opening disk image: %s\n", astring_c(filename)));
err = open_disk_image(Machine->gamedrv, romp, &chd.origfile, &chd.origchd);
if (err != CHDERR_NONE)
{
@@ -1030,7 +1029,7 @@ static void process_disk_entries(rom_load_data *romdata, const rom_entry *romp)
}
/* we're okay, add to the list of disks */
- debugload("Assigning to handle %d\n", DISK_GETINDEX(romp));
+ LOG(("Assigning to handle %d\n", DISK_GETINDEX(romp)));
*chd_list_tailptr = auto_malloc(sizeof(**chd_list_tailptr));
**chd_list_tailptr = chd;
chd_list_tailptr = &(*chd_list_tailptr)->next;
@@ -1116,7 +1115,7 @@ void rom_init(running_machine *machine, const rom_entry *romp)
UINT32 regionflags = ROMREGION_GETFLAGS(region);
int regiontype = ROMREGION_GETTYPE(region);
- debugload("Processing region %02X (length=%X)\n", regiontype, regionlength);
+ LOG(("Processing region %02X (length=%X)\n", regiontype, regionlength));
/* the first entry must be a region */
assert(ROMENTRY_ISREGION(region));
@@ -1128,7 +1127,7 @@ void rom_init(running_machine *machine, const rom_entry *romp)
/* remember the base and length */
romdata.regionbase = new_memory_region(machine, regiontype, regionlength, regionflags);
romdata.regionlength = regionlength;
- debugload("Allocated %X bytes @ %p\n", romdata.regionlength, romdata.regionbase);
+ LOG(("Allocated %X bytes @ %p\n", romdata.regionlength, romdata.regionbase));
/* clear the region if it's requested */
if (ROMREGION_ISERASE(region))
@@ -1159,7 +1158,7 @@ void rom_init(running_machine *machine, const rom_entry *romp)
for (regnum = 0; regnum < REGION_MAX; regnum++)
if (regionlist[regnum])
{
- debugload("Post-processing region %02X\n", regnum);
+ LOG(("Post-processing region %02X\n", regnum));
region_post_process(machine, &romdata, regnum);
}
diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c
index 85900c805d5..d94bac174a3 100644
--- a/src/emu/sound/bsmt2000.c
+++ b/src/emu/sound/bsmt2000.c
@@ -334,9 +334,7 @@ static void bsmt2000_update(void *param, stream_sample_t **inputs, stream_sample
static void bsmt2000_reg_write(bsmt2000_chip *chip, offs_t offset, UINT16 data)
{
-#if LOG_COMMANDS
- mame_printf_debug("BSMT write: reg %02X = %04X\n", offset, data);
-#endif
+ if (LOG_COMMANDS) mame_printf_debug("BSMT write: reg %02X = %04X\n", offset, data);
/* remember the last write */
chip->last_register = offset;
diff --git a/src/emu/sound/fmopl.c b/src/emu/sound/fmopl.c
index 820c3ed51a4..d0892a98bf4 100644
--- a/src/emu/sound/fmopl.c
+++ b/src/emu/sound/fmopl.c
@@ -186,10 +186,8 @@ static FILE *sample[1];
#endif
#endif
-/* #define LOG_CYM_FILE */
-#ifdef LOG_CYM_FILE
- FILE * cymfile = NULL;
-#endif
+#define LOG_CYM_FILE 0
+static FILE * cymfile = NULL;
@@ -1458,13 +1456,11 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
r &= 0xff;
v &= 0xff;
-#ifdef LOG_CYM_FILE
- if ((cymfile) && (r!=0) )
+ if (LOG_CYM_FILE && (cymfile) && (r!=0) )
{
fputc( (unsigned char)r, cymfile );
fputc( (unsigned char)v, cymfile );
}
-#endif
switch(r&0xe0)
@@ -1721,7 +1717,6 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
}
}
-#ifdef LOG_CYM_FILE
static TIMER_CALLBACK( cymfile_callback )
{
if (cymfile)
@@ -1729,7 +1724,6 @@ static TIMER_CALLBACK( cymfile_callback )
fputc( (unsigned char)0, cymfile );
}
}
-#endif
/* lock/unlock for common table */
static int OPL_LockTable(void)
@@ -1747,13 +1741,14 @@ static int OPL_LockTable(void)
return -1;
}
-#ifdef LOG_CYM_FILE
- cymfile = fopen("3812_.cym","wb");
- if (cymfile)
- timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
- else
- logerror("Could not create file 3812_.cym\n");
-#endif
+ if (LOG_CYM_FILE)
+ {
+ cymfile = fopen("3812_.cym","wb");
+ if (cymfile)
+ timer_pulse ( ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ else
+ logerror("Could not create file 3812_.cym\n");
+ }
return 0;
}
@@ -1768,11 +1763,9 @@ static void OPL_UnLockTable(void)
cur_chip = NULL;
OPLCloseTable();
-#ifdef LOG_CYM_FILE
- fclose (cymfile);
+ if (cymfile)
+ fclose (cymfile);
cymfile = NULL;
-#endif
-
}
static void OPLResetChip(FM_OPL *OPL)
diff --git a/src/emu/sound/gaelco.c b/src/emu/sound/gaelco.c
index 010ad23cc25..c5fcc78dabf 100644
--- a/src/emu/sound/gaelco.c
+++ b/src/emu/sound/gaelco.c
@@ -45,7 +45,7 @@ Registers per channel:
#define LOG_SOUND(x) do { if (VERBOSE_SOUND) logerror x; } while (0)
#define LOG_READ_WRITES(x) do { if (VERBOSE_READ_WRITES) logerror x; } while (0)
-//#define LOG_WAVE 1
+#define LOG_WAVE 0
//#define ALT_MIX
#define GAELCO_NUM_CHANNELS 0x07
@@ -76,9 +76,7 @@ struct GAELCOSND
INT16 volume_table[VOLUME_LEVELS][256];
};
-#ifdef LOG_WAVE
-void * wavraw; /* raw waveform */
-#endif
+static void * wavraw; /* raw waveform */
/*============================================================================
CG-1V/GAE1 Sound Update
@@ -182,9 +180,8 @@ static void gaelco_update(void *param, stream_sample_t **inputs, stream_sample_t
buffer[1][j] = output_r;
}
-#ifdef LOG_WAVE
- wav_add_data_16lr(wavraw, buffer[0], buffer[1], length);
-#endif
+ if (wavraw)
+ wav_add_data_32lr(wavraw, buffer[0], buffer[1], length, 0);
}
/*============================================================================
@@ -271,9 +268,8 @@ static void *gaelcosnd_start(sound_type sndtype, int sndindex, int clock, const
}
}
-#ifdef LOG_WAVE
- wavraw = wav_open("gae1_snd.wav", 8000, 2);
-#endif
+ if (LOG_WAVE)
+ wavraw = wav_open("gae1_snd.wav", 8000, 2);
return info;
}
@@ -291,9 +287,9 @@ static void *gaelco_cg1v_start(int sndindex, int clock, const void *config)
static void gaelco_stop(void *chip)
{
-#ifdef LOG_WAVE
- wav_close(wavraw);
-#endif
+ if (wavraw)
+ wav_close(wavraw);
+ wavraw = NULL;
}
diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c
index 5f9f621a452..892b6850823 100644
--- a/src/emu/sound/ics2115.c
+++ b/src/emu/sound/ics2115.c
@@ -73,7 +73,7 @@ static int caller_get_pc(void)
if(pc == 0x14b || pc == 0x26e || pc == 0x284 || pc == 0x28d ||
pc == 0x290 || pc == 0x299 || pc == 0x2a2 || pc == 0x2b3) {
int sp = z80_get_reg(Z80_SP);
- pc = cpu_readmem16(sp)|(cpu_readmem16((UINT16)(sp+1)) << 8);
+ pc = program_read_word(sp)|(program_read_word((UINT16)(sp+1)) << 8);
}
#endif
diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c
index f24d04ba612..795e05e419e 100644
--- a/src/emu/sound/k053260.c
+++ b/src/emu/sound/k053260.c
@@ -246,9 +246,7 @@ INLINE void check_bounds( struct K053260_chip_def *ic, int channel ) {
ic->channels[channel].size = ic->rom_size - channel_start;
}
-#if LOG
- logerror("K053260: Sample Start = %06x, Sample End = %06x, Sample rate = %04lx, PPCM = %s\n", channel_start, channel_end, ic->channels[channel].rate, ic->channels[channel].ppcm ? "yes" : "no" );
-#endif
+ if (LOG) logerror("K053260: Sample Start = %06x, Sample End = %06x, Sample rate = %04lx, PPCM = %s\n", channel_start, channel_end, ic->channels[channel].rate, ic->channels[channel].ppcm ? "yes" : "no" );
}
static void K053260_write( int chip, offs_t offset, UINT8 data )
diff --git a/src/emu/sound/qsound.c b/src/emu/sound/qsound.c
index 1244efdf023..bbbc05afb84 100644
--- a/src/emu/sound/qsound.c
+++ b/src/emu/sound/qsound.c
@@ -86,10 +86,8 @@ struct qsound_info
int pan_table[33]; /* Pan volume table */
float frq_ratio; /* Frequency ratio */
- #if LOG_WAVE
FILE *fpRawDataL;
FILE *fpRawDataR;
- #endif
};
/* Function prototypes */
@@ -132,14 +130,11 @@ static void *qsound_start(int sndindex, int clock, const void *config)
qsound_update );
}
-#if LOG_WAVE
- chip->fpRawDataR=fopen("qsoundr.raw", "w+b");
- chip->fpRawDataL=fopen("qsoundl.raw", "w+b");
- if (!chip->fpRawDataR || !chip->fpRawDataL)
+ if (LOG_WAVE)
{
- return NULL;
+ chip->fpRawDataR=fopen("qsoundr.raw", "w+b");
+ chip->fpRawDataL=fopen("qsoundl.raw", "w+b");
}
-#endif
/* state save */
for (i=0; i<QSOUND_CHANNELS; i++)
@@ -163,16 +158,17 @@ static void *qsound_start(int sndindex, int clock, const void *config)
static void qsound_stop (void *_chip)
{
-#if LOG_WAVE
+ struct qsound_info *chip = _chip;
if (chip->fpRawDataR)
{
fclose(chip->fpRawDataR);
}
+ chip->fpRawDataR = NULL;
if (chip->fpRawDataL)
{
fclose(chip->fpRawDataL);
}
-#endif
+ chip->fpRawDataL = NULL;
}
WRITE8_HANDLER( qsound_data_h_w )
@@ -365,10 +361,10 @@ static void qsound_update( void *param, stream_sample_t **inputs, stream_sample_
pC++;
}
-#if LOG_WAVE
- fwrite(datap[0], length*sizeof(QSOUND_SAMPLE), 1, chip->fpRawDataL);
- fwrite(datap[1], length*sizeof(QSOUND_SAMPLE), 1, chip->fpRawDataR);
-#endif
+ if (chip->fpRawDataL)
+ fwrite(datap[0], length*sizeof(QSOUND_SAMPLE), 1, chip->fpRawDataL);
+ if (chip->fpRawDataR)
+ fwrite(datap[1], length*sizeof(QSOUND_SAMPLE), 1, chip->fpRawDataR);
}
diff --git a/src/emu/sound/sn76477.c b/src/emu/sound/sn76477.c
index 08c89678e21..3933c9e82fa 100644
--- a/src/emu/sound/sn76477.c
+++ b/src/emu/sound/sn76477.c
@@ -31,6 +31,7 @@
#include "sndintrf.h"
#include "streams.h"
#include "deprecat.h"
+#include "wavwrite.h"
#include "sn76477.h"
@@ -258,9 +259,7 @@ struct SN76477
UINT32 index;
int sample_rate; /* from machine->sample_rate */
-#if LOG_WAV
wav_file *file; /* handle of the wave file to produce */
-#endif
};
@@ -907,10 +906,6 @@ static void log_complete_state(struct SN76477 *sn)
*
*****************************************************************************/
-#if LOG_WAV
-
-#include "wavwrite.h"
-
static void open_wav_file(struct SN76477 *sn)
{
@@ -934,8 +929,6 @@ static void add_wav_data(struct SN76477 *sn, INT16 data_l, INT16 data_r)
wav_add_data_16lr(sn->file, &data_l, &data_r, 1);
}
-#endif
-
/*****************************************************************************
@@ -2280,48 +2273,45 @@ static void SN76477_update(void *param, stream_sample_t **inputs, stream_sample_
*/
*buffer++ = (((voltage_out - OUT_LOW_CLIP_THRESHOLD) / (OUT_CENTER_LEVEL_VOLTAGE - OUT_LOW_CLIP_THRESHOLD)) - 1) * 32767;
-#if LOG_WAV
-#if LOG_WAV_ENABLED_ONLY
- if (!sn->enable)
-#endif
+ if (LOG_WAV && LOG_WAV_ENABLED_ONLY && !sn->enable)
{
INT16 log_data_l;
INT16 log_data_r;
-#if LOG_WAV_VALUE_L == 0
- log_data_l = LOG_WAV_GAIN_FACTOR * voltage_out;
-#elif LOG_WAV_VALUE_L == 1
- log_data_l = LOG_WAV_GAIN_FACTOR * sn->enable;
-#elif LOG_WAV_VALUE_L == 2
- log_data_l = LOG_WAV_GAIN_FACTOR * sn->one_shot_cap_voltage;
-#elif LOG_WAV_VALUE_L == 3
- log_data_l = LOG_WAV_GAIN_FACTOR * sn->attack_decay_cap_voltage;
-#elif LOG_WAV_VALUE_L == 4
- log_data_l = LOG_WAV_GAIN_FACTOR * sn->slf_cap_voltage;
-#elif LOG_WAV_VALUE_L == 5
- log_data_l = LOG_WAV_GAIN_FACTOR * sn->vco_cap_voltage;
-#elif LOG_WAV_VALUE_L == 6
- log_data_l = LOG_WAV_GAIN_FACTOR * sn->noise_filter_cap_voltage;
-#endif
+ switch (LOG_WAV_VALUE_L)
+ {
+ case 0:
+ log_data_l = LOG_WAV_GAIN_FACTOR * voltage_out;
+ log_data_r = LOG_WAV_GAIN_FACTOR * voltage_out;
+ break;
+ case 1:
+ log_data_l = LOG_WAV_GAIN_FACTOR * sn->enable;
+ log_data_r = LOG_WAV_GAIN_FACTOR * sn->enable;
+ break;
+ case 2:
+ log_data_l = LOG_WAV_GAIN_FACTOR * sn->one_shot_cap_voltage;
+ log_data_r = LOG_WAV_GAIN_FACTOR * sn->one_shot_cap_voltage;
+ break;
+ case 3:
+ log_data_l = LOG_WAV_GAIN_FACTOR * sn->attack_decay_cap_voltage;
+ log_data_r = LOG_WAV_GAIN_FACTOR * sn->attack_decay_cap_voltage;
+ break;
+ case 4:
+ log_data_l = LOG_WAV_GAIN_FACTOR * sn->slf_cap_voltage;
+ log_data_r = LOG_WAV_GAIN_FACTOR * sn->slf_cap_voltage;
+ break;
+ case 5:
+ log_data_l = LOG_WAV_GAIN_FACTOR * sn->vco_cap_voltage;
+ log_data_r = LOG_WAV_GAIN_FACTOR * sn->vco_cap_voltage;
+ break;
+ case 6:
+ log_data_l = LOG_WAV_GAIN_FACTOR * sn->noise_filter_cap_voltage;
+ log_data_r = LOG_WAV_GAIN_FACTOR * sn->noise_filter_cap_voltage;
+ break;
+ }
-#if LOG_WAV_VALUE_R == 0
- log_data_r = LOG_WAV_GAIN_FACTOR * voltage_out;
-#elif LOG_WAV_VALUE_R == 1
- log_data_r = LOG_WAV_GAIN_FACTOR * sn->enable;
-#elif LOG_WAV_VALUE_R == 2
- log_data_r = LOG_WAV_GAIN_FACTOR * sn->one_shot_cap_voltage;
-#elif LOG_WAV_VALUE_R == 3
- log_data_r = LOG_WAV_GAIN_FACTOR * sn->attack_decay_cap_voltage;
-#elif LOG_WAV_VALUE_R == 4
- log_data_r = LOG_WAV_GAIN_FACTOR * sn->slf_cap_voltage;
-#elif LOG_WAV_VALUE_R == 5
- log_data_r = LOG_WAV_GAIN_FACTOR * sn->vco_cap_voltage;
-#elif LOG_WAV_VALUE_R == 6
- log_data_r = LOG_WAV_GAIN_FACTOR * sn->noise_filter_cap_voltage;
-#endif
add_wav_data(sn, log_data_l, log_data_r);
}
-#endif
}
}
@@ -2465,22 +2455,20 @@ static void *sn76477_start(int sndindex, int clock, const void *config)
log_complete_state(sn);
-#if LOG_WAV
- open_wav_file(sn);
-#endif
+ if (LOG_WAV)
+ open_wav_file(sn);
return sn;
}
-#if LOG_WAV
static void sn76477_stop(void *token)
{
struct SN76477 *sn = (struct SN76477 *)token;
- close_wav_file(sn);
+ if (LOG_WAV)
+ close_wav_file(sn);
}
-#endif
void sn76477_get_info(void *token, UINT32 state, sndinfo *info)
@@ -2488,9 +2476,7 @@ void sn76477_get_info(void *token, UINT32 state, sndinfo *info)
switch (state)
{
case SNDINFO_PTR_START: info->start = sn76477_start; break;
-#if LOG_WAV
case SNDINFO_PTR_STOP: info->stop = sn76477_stop; break;
-#endif
case SNDINFO_STR_NAME: info->s = "SN76477"; break;
case SNDINFO_STR_CORE_FAMILY: info->s = "Analog"; break;
case SNDINFO_STR_CORE_VERSION: info->s = "2.1"; break;
diff --git a/src/emu/sound/ym2151.c b/src/emu/sound/ym2151.c
index 068a9fbf2a0..a109a42874a 100644
--- a/src/emu/sound/ym2151.c
+++ b/src/emu/sound/ym2151.c
@@ -22,12 +22,9 @@
#undef USE_MAME_TIMERS
#endif
#endif
-#ifdef USE_MAME_TIMERS
- /*#define LOG_CYM_FILE*/
- #ifdef LOG_CYM_FILE
- FILE * cymfile = NULL;
- #endif
-#endif
+
+#define LOG_CYM_FILE 0
+static FILE * cymfile = NULL;
/* struct describing a single operator */
@@ -1061,13 +1058,11 @@ void YM2151WriteReg(void *_chip, int r, int v)
chip->status |= 0x80; /* set busy flag for 64 chip clock cycles */
#endif
-#ifdef LOG_CYM_FILE
- if ((cymfile) && (r!=0) )
+ if (LOG_CYM_FILE && (cymfile) && (r!=0) )
{
fputc( (unsigned char)r, cymfile );
fputc( (unsigned char)v, cymfile );
}
-#endif
switch(r & 0xe0){
@@ -1364,13 +1359,11 @@ void YM2151WriteReg(void *_chip, int r, int v)
}
-#ifdef LOG_CYM_FILE
static TIMER_CALLBACK( cymfile_callback )
{
if (cymfile)
fputc( (unsigned char)0, cymfile );
}
-#endif
int YM2151ReadStatus( void *_chip )
@@ -1552,13 +1545,14 @@ void * YM2151Init(int index, int clock, int rate)
YM2151ResetChip(PSG);
/*logerror("YM2151[init] clock=%i sampfreq=%i\n", PSG->clock, PSG->sampfreq);*/
-#ifdef LOG_CYM_FILE
- cymfile = fopen("2151_.cym","wb");
- if (cymfile)
- timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
- else
- logerror("Could not create file 2151_.cym\n");
-#endif
+ if (LOG_CYM_FILE)
+ {
+ cymfile = fopen("2151_.cym","wb");
+ if (cymfile)
+ timer_pulse ( ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ else
+ logerror("Could not create file 2151_.cym\n");
+ }
return PSG;
}
@@ -1571,10 +1565,9 @@ void YM2151Shutdown(void *_chip)
free (chip);
-#ifdef LOG_CYM_FILE
- fclose (cymfile);
+ if (cymfile)
+ fclose (cymfile);
cymfile = NULL;
-#endif
#ifdef SAVE_SAMPLE
fclose(sample[8]);
diff --git a/src/emu/sound/ym2413.c b/src/emu/sound/ym2413.c
index 863ec8a279c..0e8a296fe68 100644
--- a/src/emu/sound/ym2413.c
+++ b/src/emu/sound/ym2413.c
@@ -160,10 +160,8 @@ static FILE *sample[1];
#endif
#endif
-/*#define LOG_CYM_FILE*/
-#ifdef LOG_CYM_FILE
- FILE * cymfile = NULL;
-#endif
+#define LOG_CYM_FILE 0
+static FILE * cymfile = NULL;
@@ -1661,13 +1659,11 @@ static void OPLLWriteReg(YM2413 *chip, int r, int v)
v &= 0xff;
-#ifdef LOG_CYM_FILE
- if ((cymfile) && (r!=8) )
+ if (LOG_CYM_FILE && (cymfile) && (r!=8) )
{
fputc( (unsigned char)r, cymfile );
fputc( (unsigned char)v, cymfile );
}
-#endif
switch(r&0xf0)
@@ -1916,7 +1912,6 @@ static void OPLLWriteReg(YM2413 *chip, int r, int v)
}
}
-#ifdef LOG_CYM_FILE
static TIMER_CALLBACK( cymfile_callback )
{
if (cymfile)
@@ -1924,7 +1919,6 @@ static TIMER_CALLBACK( cymfile_callback )
fputc( (unsigned char)8, cymfile );
}
}
-#endif
/* lock/unlock for common table */
static int OPLL_LockTable(void)
@@ -1942,13 +1936,14 @@ static int OPLL_LockTable(void)
return -1;
}
-#ifdef LOG_CYM_FILE
- cymfile = fopen("2413_.cym","wb");
- if (cymfile)
- timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
- else
- logerror("Could not create file 2413_.cym\n");
-#endif
+ if (LOG_CYM_FILE)
+ {
+ cymfile = fopen("2413_.cym","wb");
+ if (cymfile)
+ timer_pulse ( ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ else
+ logerror("Could not create file 2413_.cym\n");
+ }
return 0;
}
@@ -1963,11 +1958,9 @@ static void OPLL_UnLockTable(void)
cur_chip = NULL;
OPLCloseTable();
-#ifdef LOG_CYM_FILE
- fclose (cymfile);
+ if (cymfile)
+ fclose (cymfile);
cymfile = NULL;
-#endif
-
}
static void OPLLResetChip(YM2413 *chip)
diff --git a/src/emu/sound/ymf262.c b/src/emu/sound/ymf262.c
index 98b219b2c4d..6e4312900f8 100644
--- a/src/emu/sound/ymf262.c
+++ b/src/emu/sound/ymf262.c
@@ -133,10 +133,8 @@ static FILE *sample[1];
#endif
#endif
-/*#define LOG_CYM_FILE*/
-#ifdef LOG_CYM_FILE
- FILE * cymfile = NULL;
-#endif
+#define LOG_CYM_FILE 0
+static FILE * cymfile = NULL;
@@ -1623,8 +1621,7 @@ static void OPL3WriteReg(OPL3 *chip, int r, int v)
-#ifdef LOG_CYM_FILE
- if ((cymfile) && ((r&255)!=0) && (r!=255) )
+ if (LOG_CYM_FILE && (cymfile) && ((r&255)!=0) && (r!=255) )
{
if (r>0xff)
fputc( (unsigned char)0xff, cymfile );/*mark writes to second register set*/
@@ -1632,7 +1629,6 @@ static void OPL3WriteReg(OPL3 *chip, int r, int v)
fputc( (unsigned char)r&0xff, cymfile );
fputc( (unsigned char)v, cymfile );
}
-#endif
if(r&0x100)
{
@@ -2240,7 +2236,6 @@ static void OPL3WriteReg(OPL3 *chip, int r, int v)
}
}
-#ifdef LOG_CYM_FILE
static TIMER_CALLBACK( cymfile_callback )
{
if (cymfile)
@@ -2248,7 +2243,6 @@ static TIMER_CALLBACK( cymfile_callback )
fputc( (unsigned char)0, cymfile );
}
}
-#endif
/* lock/unlock for common table */
static int OPL3_LockTable(void)
@@ -2266,13 +2260,14 @@ static int OPL3_LockTable(void)
return -1;
}
-#ifdef LOG_CYM_FILE
- cymfile = fopen("ymf262_.cym","wb");
- if (cymfile)
- timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
- else
- logerror("Could not create ymf262_.cym file\n");
-#endif
+ if (LOG_CYM_FILE)
+ {
+ cymfile = fopen("ymf262_.cym","wb");
+ if (cymfile)
+ timer_pulse ( ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ else
+ logerror("Could not create ymf262_.cym file\n");
+ }
return 0;
}
@@ -2287,11 +2282,9 @@ static void OPL3_UnLockTable(void)
cur_chip = NULL;
OPLCloseTable();
-#ifdef LOG_CYM_FILE
- fclose (cymfile);
+ if (LOG_CYM_FILE)
+ fclose (cymfile);
cymfile = NULL;
-#endif
-
}
static void OPL3ResetChip(OPL3 *chip)
diff --git a/src/emu/video/resnet.c b/src/emu/video/resnet.c
index e3ead2d26e8..387b12d37f7 100644
--- a/src/emu/video/resnet.c
+++ b/src/emu/video/resnet.c
@@ -203,7 +203,8 @@ double compute_resistor_weights(
}
/* debug code */
-#if VERBOSE
+if (VERBOSE)
+{
logerror("compute_resistor_weights(): scaler = %15.10f\n",scale);
logerror("min val :%i max val:%i Total number of networks :%i\n", minval, maxval, networks_no );
@@ -224,7 +225,7 @@ double compute_resistor_weights(
}
logerror(" sum of scaled weights = %15.10f\n", sum );
}
-#endif
+}
/* debug end */
return (scale);
@@ -396,7 +397,8 @@ double compute_resistor_net_outputs(
}
/* debug code */
-#if VERBOSE
+if (VERBOSE)
+{
logerror("compute_resistor_net_outputs(): scaler = %15.10f\n",scale);
logerror("min val :%i max val:%i Total number of networks :%i\n", minval, maxval, networks_no );
@@ -418,7 +420,7 @@ double compute_resistor_net_outputs(
logerror(" combination %2i out=%10.5f (scaled = %15.10f)\n", n, o[i*(1<<MAX_RES_PER_NET)+n], os[i*(1<<MAX_RES_PER_NET)+n] );
}
}
-#endif
+}
/* debug end */
free(o);
diff --git a/src/emu/video/v9938.c b/src/emu/video/v9938.c
index e5edc3ba302..4ea90db04cf 100644
--- a/src/emu/video/v9938.c
+++ b/src/emu/video/v9938.c
@@ -19,12 +19,7 @@
#include "v9938.h"
#define VERBOSE 0
-
-#if VERBOSE
-#define LOG(x) logerror x
-#else
-#define LOG(x)
-#endif
+#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
typedef struct {
/* general */
@@ -2423,7 +2418,6 @@ static UINT8 v9938_vdp_to_cpu (void)
/*************************************************************/
static void ReportVdpCommand(register UINT8 Op)
{
-#if VERBOSE
static const char *const Ops[16] =
{
"SET ","AND ","OR ","XOR ","NOT ","NOP ","NOP ","NOP ",
@@ -2434,7 +2428,6 @@ static void ReportVdpCommand(register UINT8 Op)
" ABRT"," ????"," ????"," ????","POINT"," PSET"," SRCH"," LINE",
" LMMV"," LMMM"," LMCM"," LMMC"," HMMV"," HMMM"," YMMM"," HMMC"
};
-#endif
register UINT8 CL, CM, LO;
register int SX,SY, DX,DY, NX,NY;
diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c
index e34255aa93f..d9083fc73e1 100644
--- a/src/lib/util/chd.c
+++ b/src/lib/util/chd.c
@@ -812,9 +812,7 @@ void chd_close(chd_file *chd)
if (chd->owns_file && chd->file != NULL)
core_fclose(chd->file);
-#if PRINTF_MAX_HUNK
- printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks);
-#endif
+ if (PRINTF_MAX_HUNK) printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks);
/* free our memory */
free(chd);
diff --git a/src/mame/audio/blockade.c b/src/mame/audio/blockade.c
index 2fbba8077a4..778e009eba7 100644
--- a/src/mame/audio/blockade.c
+++ b/src/mame/audio/blockade.c
@@ -4,6 +4,8 @@
#include "sound/discrete.h"
#include "sound/samples.h"
+#define BLOCKADE_LOG 0
+
/*
* This still needs the noise generator stuff,
* along with proper mixing and volume control
@@ -42,18 +44,14 @@ WRITE8_HANDLER( blockade_sound_freq_w )
WRITE8_HANDLER( blockade_env_on_w )
{
-//#ifdef BLOCKADE_LOG
-// mame_printf_debug("Boom Start\n");
-//#endif
+ if (BLOCKADE_LOG) mame_printf_debug("Boom Start\n");
sample_start(0,0,0);
return;
}
WRITE8_HANDLER( blockade_env_off_w )
{
-//#ifdef BLOCKADE_LOG
-// mame_printf_debug("Boom End\n");
-//#endif
+ if (BLOCKADE_LOG) mame_printf_debug("Boom End\n");
return;
}
diff --git a/src/mame/drivers/atarigt.c b/src/mame/drivers/atarigt.c
index 0aec3e6f621..c6c11e58716 100644
--- a/src/mame/drivers/atarigt.c
+++ b/src/mame/drivers/atarigt.c
@@ -286,9 +286,7 @@ static void tmek_update_mode(offs_t offset)
static void tmek_protection_w(offs_t offset, UINT16 data)
{
-#if LOG_PROTECTION
- logerror("%06X:Protection W@%06X = %04X\n", activecpu_get_previouspc(), offset, data);
-#endif
+ if (LOG_PROTECTION) logerror("%06X:Protection W@%06X = %04X\n", activecpu_get_previouspc(), offset, data);
/* track accesses */
tmek_update_mode(offset);
@@ -303,9 +301,7 @@ static void tmek_protection_w(offs_t offset, UINT16 data)
static void tmek_protection_r(offs_t offset, UINT16 *data)
{
-#if LOG_PROTECTION
- logerror("%06X:Protection R@%06X\n", activecpu_get_previouspc(), offset);
-#endif
+ if (LOG_PROTECTION) logerror("%06X:Protection R@%06X\n", activecpu_get_previouspc(), offset);
/* track accesses */
tmek_update_mode(offset);
@@ -347,21 +343,21 @@ static void primage_update_mode(offs_t offset)
/* this is from the code at $20f90 */
if (protaddr[1] == 0xdcc7c4 && protaddr[2] == 0xdcc7c4 && protaddr[3] == 0xdc4010)
{
-// logerror("prot:Entering mode 1\n");
+ if (LOG_PROTECTION) logerror("prot:Entering mode 1\n");
protmode = 1;
}
/* this is from the code at $27592 */
if (protaddr[0] == 0xdcc7ca && protaddr[1] == 0xdcc7ca && protaddr[2] == 0xdcc7c6 && protaddr[3] == 0xdc4022)
{
-// logerror("prot:Entering mode 2\n");
+ if (LOG_PROTECTION) logerror("prot:Entering mode 2\n");
protmode = 2;
}
/* this is from the code at $3d8dc */
if (protaddr[0] == 0xdcc7c0 && protaddr[1] == 0xdcc7c0 && protaddr[2] == 0xdc80f2 && protaddr[3] == 0xdc7af2)
{
-// logerror("prot:Entering mode 3\n");
+ if (LOG_PROTECTION) logerror("prot:Entering mode 3\n");
protmode = 3;
}
}
@@ -371,8 +367,8 @@ static void primage_update_mode(offs_t offset)
static void primrage_protection_w(offs_t offset, UINT16 data)
{
-#if LOG_PROTECTION
-{
+ if (LOG_PROTECTION)
+ {
UINT32 pc = activecpu_get_previouspc();
switch (pc)
{
@@ -409,8 +405,7 @@ static void primrage_protection_w(offs_t offset, UINT16 data)
logerror("%06X:Unknown protection W@%06X = %04X\n", activecpu_get_previouspc(), offset, data);
break;
}
-}
-#endif
+ }
/* mask = 0x78fff */
@@ -424,7 +419,7 @@ static void primrage_protection_w(offs_t offset, UINT16 data)
if (protmode == 2)
{
int temp = (offset - 0xdc7800) / 2;
-// logerror("prot:mode 2 param = %04X\n", temp);
+ if (LOG_PROTECTION) logerror("prot:mode 2 param = %04X\n", temp);
protresult = temp * 0x6915 + 0x6915;
}
@@ -432,7 +427,7 @@ static void primrage_protection_w(offs_t offset, UINT16 data)
{
if (offset == 0xdc4700)
{
-// logerror("prot:Clearing mode 3\n");
+ if (LOG_PROTECTION) logerror("prot:Clearing mode 3\n");
protmode = 0;
}
}
@@ -445,7 +440,7 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
/* track accesses */
primage_update_mode(offset);
-#if LOG_PROTECTION
+if (LOG_PROTECTION)
{
UINT32 pc = activecpu_get_previouspc();
UINT32 p1, p2, a6;
@@ -468,8 +463,8 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
break;
case 0x275cc:
a6 = activecpu_get_reg(M68K_A6);
- p1 = (cpu_readmem24bedw_word(a6+8) << 16) | cpu_readmem24bedw_word(a6+10);
- p2 = (cpu_readmem24bedw_word(a6+12) << 16) | cpu_readmem24bedw_word(a6+14);
+ p1 = (program_read_word(a6+8) << 16) | program_read_word(a6+10);
+ p2 = (program_read_word(a6+12) << 16) | program_read_word(a6+14);
logerror("Known Protection @ 275BC(%08X, %08X): R@%06X ", p1, p2, offset);
break;
case 0x275d2:
@@ -486,7 +481,7 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
/* protection code from 3d8dc - 3d95a */
case 0x3d8f4:
a6 = activecpu_get_reg(M68K_A6);
- p1 = (cpu_readmem24bedw_word(a6+12) << 16) | cpu_readmem24bedw_word(a6+14);
+ p1 = (program_read_word(a6+12) << 16) | program_read_word(a6+14);
logerror("Known Protection @ 3D8F4(%08X): R@%06X ", p1, offset);
break;
case 0x3d8fa:
@@ -497,7 +492,7 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
/* protection code from 437fa - 43860 */
case 0x43814:
a6 = activecpu_get_reg(M68K_A6);
- p1 = cpu_readmem24bedw(a6+15);
+ p1 = program_read_dword(a6+14) & 0xffffff;
logerror("Known Protection @ 43814(%08X): R@%06X ", p1, offset);
break;
case 0x4381c:
@@ -514,7 +509,6 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
break;
}
}
-#endif
/* handle specific reads */
switch (offset)
@@ -533,7 +527,7 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
{
*data = protresult;
protmode = 0;
-// logerror("prot:Clearing mode 2\n");
+ if (LOG_PROTECTION) logerror("prot:Clearing mode 2\n");
}
break;
@@ -541,7 +535,7 @@ static void primrage_protection_r(offs_t offset, UINT16 *data)
if (protmode == 1)
{
protmode = 0;
-// logerror("prot:Clearing mode 1\n");
+ if (LOG_PROTECTION) logerror("prot:Clearing mode 1\n");
}
break;
}
diff --git a/src/mame/drivers/blockade.c b/src/mame/drivers/blockade.c
index f27939a435c..711b2b117e4 100644
--- a/src/mame/drivers/blockade.c
+++ b/src/mame/drivers/blockade.c
@@ -33,7 +33,7 @@ Notes: Support is complete with the exception of the noise generator.
#include "sound/samples.h"
#include "sound/discrete.h"
-/* #define BLOCKADE_LOG 1 */
+#define BLOCKADE_LOG 0
/* These are used to simulate coin latch circuitry */
@@ -86,9 +86,7 @@ static WRITE8_HANDLER( blockade_coin_latch_w )
{
if (data & 0x80)
{
- #ifdef BLOCKADE_LOG
- mame_printf_debug("Reset Coin Latch\n");
- #endif
+ if (BLOCKADE_LOG) mame_printf_debug("Reset Coin Latch\n");
if (just_been_reset)
{
just_been_reset = 0;
@@ -100,15 +98,11 @@ static WRITE8_HANDLER( blockade_coin_latch_w )
if (data & 0x20)
{
- #ifdef BLOCKADE_LOG
- mame_printf_debug("Pin 19 High\n");
- #endif
+ if (BLOCKADE_LOG) mame_printf_debug("Pin 19 High\n");
}
else
{
- #ifdef BLOCKADE_LOG
- mame_printf_debug("Pin 19 Low\n");
- #endif
+ if (BLOCKADE_LOG) mame_printf_debug("Pin 19 Low\n");
}
return;
diff --git a/src/mame/drivers/guab.c b/src/mame/drivers/guab.c
index c2364ed1fc2..41d3049b07d 100644
--- a/src/mame/drivers/guab.c
+++ b/src/mame/drivers/guab.c
@@ -32,12 +32,7 @@
*************************************/
#define LOG_FDC_COMMANDS 0
-
-#if LOG_FDC_COMMANDS
- #define FDC_LOG(x) mame_printf_debug x
-#else
- #define FDC_LOG(x)
-#endif
+#define FDC_LOG(x) do { if (LOG_FDC_COMMANDS) mame_printf_debug x; } while(0)
enum
diff --git a/src/mame/drivers/rabbit.c b/src/mame/drivers/rabbit.c
index 502405e6fcb..e9558fd1f40 100644
--- a/src/mame/drivers/rabbit.c
+++ b/src/mame/drivers/rabbit.c
@@ -550,9 +550,10 @@ static WRITE32_HANDLER ( rabbit_rombank_w )
static WRITE32_HANDLER( rabbit_audio_w )
{
-#if VERBOSE_AUDIO_LOG
int reg, voice, base, i;
+if (VERBOSE_AUDIO_LOG)
+{
if (mem_mask == 0xffff0000)
{
reg = offset*2;
@@ -602,7 +603,7 @@ static WRITE32_HANDLER( rabbit_audio_w )
logerror("Unknown write %04x to global reg %d\n", data, reg);
}
}
-#endif
+}
}
#define BLITCMDLOG 0
diff --git a/src/mame/drivers/thunderj.c b/src/mame/drivers/thunderj.c
index 459153a86a0..1727d6fe735 100644
--- a/src/mame/drivers/thunderj.c
+++ b/src/mame/drivers/thunderj.c
@@ -174,10 +174,12 @@ static READ16_HANDLER( thunderj_atarivc_r )
memory (which is what it does if this interrupt test fails -- see the code
at $1E56 to see!) */
- /* Use these lines to detect when things go south:
+ /* Use these lines to detect when things go south: */
- if (cpu_readmem24bew_word(0x163482) > 0xfff)
- mame_printf_debug("You're screwed!");*/
+#if 0
+ if (program_read_word(0x163482) > 0xfff)
+ mame_printf_debug("You're screwed!");
+#endif
return atarivc_r(machine->primary_screen, offset);
}
diff --git a/src/mame/machine/asic65.c b/src/mame/machine/asic65.c
index 16cc127175d..8ad12f4e3f0 100644
--- a/src/mame/machine/asic65.c
+++ b/src/mame/machine/asic65.c
@@ -185,9 +185,7 @@ static TIMER_CALLBACK( m68k_asic65_deferred_w )
WRITE16_HANDLER( asic65_data_w )
{
/* logging */
-#if LOG_ASIC
- if (!asic65_log) asic65_log = fopen("asic65.log", "w");
-#endif
+ if (LOG_ASIC && !asic65_log) asic65_log = fopen("asic65.log", "w");
/* rom-based use a deferred write mechanism */
if (asic65_type == ASIC65_ROMBASED)
@@ -434,9 +432,7 @@ READ16_HANDLER( asic65_r )
}
}
-#if LOG_ASIC
- if (!asic65_log) asic65_log = fopen("asic65.log", "w");
-#endif
+ if (LOG_ASIC && !asic65_log) asic65_log = fopen("asic65.log", "w");
if (asic65_log) fprintf(asic65_log, " (R=%04X)", result);
return result;
diff --git a/src/mame/machine/cubocd32.c b/src/mame/machine/cubocd32.c
index 047efa34d3f..fbbcb38de8a 100644
--- a/src/mame/machine/cubocd32.c
+++ b/src/mame/machine/cubocd32.c
@@ -241,7 +241,6 @@ static UINT32 akiko_c2p_read(void)
return val;
}
-#if LOG_AKIKO
static const char *const akiko_reg_names[] =
{
/*0*/ "ID",
@@ -272,7 +271,6 @@ const char* get_akiko_reg_name(int reg)
return "???";
}
}
-#endif
/*************************************
*
@@ -358,9 +356,7 @@ static void akiko_set_cd_status( UINT32 status )
if ( akiko.cdrom_status[0] & akiko.cdrom_status[1] )
{
-#if LOG_AKIKO_CD
- logerror( "Akiko CD IRQ\n" );
-#endif
+ if (LOG_AKIKO_CD) logerror( "Akiko CD IRQ\n" );
amiga_custom_w(Machine, REG_INTREQ, 0x8000 | INTENA_PORTS, 0xffff);
}
}
@@ -462,9 +458,7 @@ static TIMER_CALLBACK(akiko_dma_proc)
}
}
-#if LOG_AKIKO_CD
- logerror( "DMA: sector %d - address %08x\n", akiko.cdrom_lba_cur, akiko.cdrom_address[0] + (index*4096) );
-#endif
+ if (LOG_AKIKO_CD) logerror( "DMA: sector %d - address %08x\n", akiko.cdrom_lba_cur, akiko.cdrom_address[0] + (index*4096) );
for( i = 0; i < 2352; i += 2 )
{
@@ -551,9 +545,7 @@ static TIMER_CALLBACK( akiko_cd_delayed_cmd )
if ( param == 0x05 )
{
-#if LOG_AKIKO_CD
- logerror( "AKIKO: Completing Command %d\n", param );
-#endif
+ if (LOG_AKIKO_CD) logerror( "AKIKO: Completing Command %d\n", param );
resp[0] = 0x06;
@@ -591,9 +583,7 @@ static void akiko_update_cdrom( void )
cmd &= 0x0f;
-#if LOG_AKIKO_CD
- logerror( "CDROM command: %02X\n", cmd );
-#endif
+ if (LOG_AKIKO_CD) logerror( "CDROM command: %02X\n", cmd );
if ( cmd == 0x02 ) /* pause audio */
{
@@ -651,9 +641,7 @@ static void akiko_update_cdrom( void )
if ( cmdbuf[7] == 0x80 )
{
-#if LOG_AKIKO_CD
- logerror( "AKIKO CD: PC:%06x Data read - start lba: %08x - end lba: %08x\n", safe_activecpu_get_pc(), startpos, endpos );
-#endif
+ if (LOG_AKIKO_CD) logerror( "AKIKO CD: PC:%06x Data read - start lba: %08x - end lba: %08x\n", safe_activecpu_get_pc(), startpos, endpos );
akiko.cdrom_speed = (cmdbuf[8] & 0x40) ? 2 : 1;
akiko.cdrom_lba_start = startpos;
akiko.cdrom_lba_end = endpos;
@@ -668,9 +656,7 @@ static void akiko_update_cdrom( void )
}
else
{
-#if LOG_AKIKO_CD
- logerror( "AKIKO CD: Seek - start lba: %08x - end lba: %08x\n", startpos, endpos );
-#endif
+ if (LOG_AKIKO_CD) logerror( "AKIKO CD: Seek - start lba: %08x - end lba: %08x\n", startpos, endpos );
akiko.cdrom_track_index = 0;
for( i = 0; i < cdrom_get_last_track(akiko.cdrom); i++ )
@@ -763,12 +749,10 @@ READ32_HANDLER(amiga_akiko32_r)
{
UINT32 retval;
-#if LOG_AKIKO
- if ( offset < (0x30/4) )
+ if ( LOG_AKIKO && offset < (0x30/4) )
{
logerror( "Reading AKIKO reg %0x [%s] at PC=%06x\n", offset, get_akiko_reg_name(offset), activecpu_get_pc() );
}
-#endif
switch( offset )
{
@@ -825,12 +809,10 @@ READ32_HANDLER(amiga_akiko32_r)
WRITE32_HANDLER(amiga_akiko32_w)
{
-#if LOG_AKIKO
- if ( offset < (0x30/4) )
+ if ( LOG_AKIKO && offset < (0x30/4) )
{
logerror( "Writing AKIKO reg %0x [%s] with %08x at PC=%06x\n", offset, get_akiko_reg_name(offset), data, activecpu_get_pc() );
}
-#endif
switch( offset )
{
@@ -869,9 +851,7 @@ WRITE32_HANDLER(amiga_akiko32_w)
break;
case 0x20/4: /* CDROM DMA SECTOR READ REQUEST WRITE */
-#if LOG_AKIKO_CD
- logerror( "Read Req mask W: data %08x - mem mask %08x\n", data, mem_mask );
-#endif
+ if (LOG_AKIKO_CD) logerror( "Read Req mask W: data %08x - mem mask %08x\n", data, mem_mask );
if ( ACCESSING_BITS_16_31 )
{
akiko.cdrom_readreqmask = (data >> 16);
@@ -880,9 +860,7 @@ WRITE32_HANDLER(amiga_akiko32_w)
break;
case 0x24/4: /* CDROM DMA ENABLE? */
-#if LOG_AKIKO_CD
- logerror( "DMA enable W: data %08x - mem mask %08x\n", data, mem_mask );
-#endif
+ if (LOG_AKIKO_CD) logerror( "DMA enable W: data %08x - mem mask %08x\n", data, mem_mask );
if ( ( akiko.cdrom_dmacontrol ^ data ) & 0x04000000 )
{
if ( data & 0x04000000 )
diff --git a/src/mame/machine/harddriv.c b/src/mame/machine/harddriv.c
index e400b62e3c3..4a20ef45715 100644
--- a/src/mame/machine/harddriv.c
+++ b/src/mame/machine/harddriv.c
@@ -912,8 +912,7 @@ WRITE16_HANDLER( hd68k_adsp_buffer_w )
static TIMER_CALLBACK( deferred_adsp_bank_switch )
{
-#if LOG_COMMANDS
- if (m68k_adsp_buffer_bank != param && input_code_pressed(KEYCODE_L))
+ if (LOG_COMMANDS && m68k_adsp_buffer_bank != param && input_code_pressed(KEYCODE_L))
{
static FILE *commands;
if (!commands) commands = fopen("commands.log", "w");
@@ -956,7 +955,7 @@ static TIMER_CALLBACK( deferred_adsp_bank_switch )
fprintf(commands, " %04X\n", *current++);
}
}
-#endif
+
m68k_adsp_buffer_bank = param;
logerror("ADSP bank = %d\n", param);
}
diff --git a/src/mame/machine/slapstic.c b/src/mame/machine/slapstic.c
index d4579bae9f8..1a3108e8c7e 100644
--- a/src/mame/machine/slapstic.c
+++ b/src/mame/machine/slapstic.c
@@ -794,13 +794,8 @@ static UINT8 bit_xor;
static struct slapstic_data slapstic;
-#if LOG_SLAPSTIC
- static void slapstic_log(offs_t offset);
- static FILE *slapsticlog;
-#else
- #define slapstic_log(o)
-#endif
-
+static void slapstic_log(offs_t offset);
+static FILE *slapsticlog;
/*************************************
@@ -1123,7 +1118,8 @@ int slapstic_tweak(offs_t offset)
}
/* log this access */
- slapstic_log(offset);
+ if (LOG_SLAPSTIC)
+ slapstic_log(offset);
/* return the active bank */
return current_bank;
@@ -1137,7 +1133,6 @@ int slapstic_tweak(offs_t offset)
*
*************************************/
-#if LOG_SLAPSTIC
static void slapstic_log(offs_t offset)
{
static attotime last_time;
@@ -1192,4 +1187,3 @@ static void slapstic_log(offs_t offset)
fflush(slapsticlog);
}
}
-#endif
diff --git a/src/mame/video/jagobj.c b/src/mame/video/jagobj.c
index dfb8aed991b..eab17a54c0d 100644
--- a/src/mame/video/jagobj.c
+++ b/src/mame/video/jagobj.c
@@ -912,11 +912,7 @@ static void process_object_list(running_machine *machine, int vc, UINT16 *_scanl
for (x = 0; x < 336; x++)
scanline[x] = gpu_regs[BG];
-#if LOG_OBJECTS
- logit = (y == cliprect->min_y);
-#else
- logit = 0;
-#endif
+ logit = LOG_OBJECTS;
/* fetch the object pointer */
objdata = (UINT32 *)get_jaguar_memory((gpu_regs[OLP_H] << 16) | gpu_regs[OLP_L]);
diff --git a/src/mame/video/jaguar.c b/src/mame/video/jaguar.c
index c89e70b0908..0a2a3091bff 100644
--- a/src/mame/video/jaguar.c
+++ b/src/mame/video/jaguar.c
@@ -551,7 +551,7 @@ static void blitter_run(void)
#endif
-#if LOG_BLITTER_STATS
+if (LOG_BLITTER_STATS)
{
static UINT32 blitter_stats[1000][4];
static UINT64 blitter_pixels[1000];
@@ -584,7 +584,6 @@ if (++reps % 100 == 99)
mame_printf_debug("---\n");
}
}
-#endif
generic_blitter(blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
profiler_mark(PROFILER_END);
diff --git a/src/mame/video/midtunit.c b/src/mame/video/midtunit.c
index 00d7765563c..a7b80f82e2a 100644
--- a/src/mame/video/midtunit.c
+++ b/src/mame/video/midtunit.c
@@ -718,7 +718,8 @@ WRITE16_HANDLER( midtunit_dma_w )
/* determine the offset */
gfxoffset = dma_register[DMA_OFFSETLO] | (dma_register[DMA_OFFSETHI] << 16);
-#if LOG_DMA
+if (LOG_DMA)
+{
if (input_code_pressed(KEYCODE_L))
{
logerror("DMA command %04X: (bpp=%d skip=%d xflip=%d yflip=%d preskip=%d postskip=%d)\n",
@@ -734,8 +735,7 @@ WRITE16_HANDLER( midtunit_dma_w )
dma_register[DMA_CONFIG]);
logerror("----\n");
}
-#endif
-
+}
/* special case: drawing mode C doesn't need to know about any pixel data */
if ((command & 0x0f) == 0x0c)
gfxoffset = 0;
diff --git a/src/mame/video/midyunit.c b/src/mame/video/midyunit.c
index b2df2e42476..486f9b35776 100644
--- a/src/mame/video/midyunit.c
+++ b/src/mame/video/midyunit.c
@@ -457,7 +457,8 @@ WRITE16_HANDLER( midyunit_dma_w )
if (!(command & 0x8000))
return;
-#if LOG_DMA
+if (LOG_DMA)
+{
if (input_code_pressed(KEYCODE_L))
{
logerror("----\n");
@@ -470,7 +471,7 @@ WRITE16_HANDLER( midyunit_dma_w )
logerror(" palette=%04X color=%04X\n",
dma_register[DMA_PALETTE], dma_register[DMA_COLOR]);
}
-#endif
+}
profiler_mark(PROFILER_USER1);
diff --git a/src/mame/video/n64.c b/src/mame/video/n64.c
index ad9aa00e28d..4d5d30e4c31 100644
--- a/src/mame/video/n64.c
+++ b/src/mame/video/n64.c
@@ -8,9 +8,7 @@
#define LOG_RDP_EXECUTION 0
-#if LOG_RDP_EXECUTION
static FILE *rdp_exec;
-#endif
static UINT32 rdp_cmd_data[0x1000];
static int rdp_cmd_ptr = 0;
@@ -262,9 +260,8 @@ while (0)
VIDEO_START(n64)
{
-#if LOG_RDP_EXECUTION
- rdp_exec = fopen("rdp_execute.txt", "wt");
-#endif
+ if (LOG_RDP_EXECUTION)
+ rdp_exec = fopen("rdp_execute.txt", "wt");
texture_cache = auto_malloc(0x100000);
@@ -2485,10 +2482,8 @@ INLINE UINT32 READ_RDP_DATA(UINT32 address)
}
}
-#if LOG_RDP_EXECUTION
static const char *const image_format[] = { "RGBA", "YUV", "CI", "IA", "I", "???", "???", "???" };
static const char *const image_size[] = { "4-bit", "8-bit", "16-bit", "32-bit" };
-#endif
static const int rdp_command_length[64] =
{
@@ -2558,7 +2553,6 @@ static const int rdp_command_length[64] =
8 // 0x3f, Set_Color_Image
};
-#if LOG_RDP_EXECUTION
static int rdp_dasm(char *buffer)
{
int i;
@@ -2865,7 +2859,6 @@ static int rdp_dasm(char *buffer)
return rdp_command_length[command];
}
-#endif
/*****************************************************************************/
@@ -3496,14 +3489,13 @@ void rdp_process_list(void)
//fatalerror("rdp_process_list: not enough rdp command data: cur = %d, ptr = %d, expected = %d\n", rdp_cmd_cur, rdp_cmd_ptr, rdp_command_length[cmd]);
}
-#if LOG_RDP_EXECUTION
+ if (LOG_RDP_EXECUTION)
{
char string[4000];
rdp_dasm(string);
fprintf(rdp_exec, "%08X: %08X %08X %s\n", dp_start+(rdp_cmd_cur * 4), rdp_cmd_data[rdp_cmd_cur+0], rdp_cmd_data[rdp_cmd_cur+1], string);
}
-#endif
// execute the command
rdp_command_table[cmd](rdp_cmd_data[rdp_cmd_cur+0], rdp_cmd_data[rdp_cmd_cur+1]);
diff --git a/src/mame/video/segas32.c b/src/mame/video/segas32.c
index 734799f6238..ebb2af0930c 100644
--- a/src/mame/video/segas32.c
+++ b/src/mame/video/segas32.c
@@ -2378,7 +2378,6 @@ static void mix_all_layers(int which, int xoffs, bitmap_t *bitmap, const rectang
static void print_mixer_data(int which)
{
-#if PRINTF_MIXER_DATA
static int count = 0;
if (++count > 60 * 5)
{
@@ -2446,7 +2445,6 @@ static void print_mixer_data(int which)
mixer_control[which][0x2f]);
count = 0;
}
-#endif
}
VIDEO_UPDATE( system32 )
@@ -2486,9 +2484,7 @@ VIDEO_UPDATE( system32 )
mix_all_layers(0, 0, bitmap, cliprect, enablemask);
profiler_mark(PROFILER_END);
-#if LOG_SPRITES
-{
- if (input_code_pressed(KEYCODE_L))
+ if (LOG_SPRITES && input_code_pressed(KEYCODE_L))
{
const rectangle *visarea = video_screen_get_visible_area(screen);
FILE *f = fopen("sprite.txt", "w");
@@ -2543,8 +2539,6 @@ VIDEO_UPDATE( system32 )
}
fclose(f);
}
-}
-#endif
#if SHOW_ALPHA
{
@@ -2626,7 +2620,7 @@ for (showclip = 0; showclip < 4; showclip++)
}
#endif
- print_mixer_data(0);
+ if (PRINTF_MIXER_DATA) print_mixer_data(0);
return 0;
}
@@ -2670,11 +2664,12 @@ VIDEO_UPDATE( multi32 )
mix_all_layers(((screen == left_screen) ? 0 : 1), 0, bitmap, cliprect, enablemask);
profiler_mark(PROFILER_END);
+if (PRINTF_MIXER_DATA)
+{
if (!input_code_pressed(KEYCODE_M)) print_mixer_data(0);
else print_mixer_data(1);
-#if LOG_SPRITES
-{
- if (input_code_pressed(KEYCODE_L))
+}
+ if (LOG_SPRITES && input_code_pressed(KEYCODE_L))
{
const rectangle *visarea = video_screen_get_visible_area(screen);
FILE *f = fopen("sprite.txt", "w");
@@ -2689,8 +2684,6 @@ VIDEO_UPDATE( multi32 )
}
fclose(f);
}
-}
-#endif
return 0;
}
diff --git a/src/mame/video/tx1.c b/src/mame/video/tx1.c
index af54eca6ba8..514e1b66612 100644
--- a/src/mame/video/tx1.c
+++ b/src/mame/video/tx1.c
@@ -21,7 +21,8 @@ READ16_HANDLER( tx1_crtc_r )
WRITE16_HANDLER( tx1_crtc_w )
{
-#if PRINT_CRTC_DATA
+if (PRINT_CRTC_DATA)
+{
data &= 0xff;
if (offset == 0)
{
@@ -51,7 +52,7 @@ WRITE16_HANDLER( tx1_crtc_w )
{
mame_printf_debug("0x%.2x, (%d)\n",data, data);
}
-#endif
+}
}
diff --git a/src/osd/windows/sound.c b/src/osd/windows/sound.c
index 69e06fbf865..16cb5f6b75a 100644
--- a/src/osd/windows/sound.c
+++ b/src/osd/windows/sound.c
@@ -35,6 +35,7 @@
#define LOG_SOUND 0
+#define LOG(x) do { if (LOG_SOUND) logerror x; } while(0)
//============================================================
@@ -61,12 +62,6 @@ static WAVEFORMATEX stream_format;
static int buffer_underflows;
static int buffer_overflows;
-// debugging
-#if LOG_SOUND
-static FILE * sound_log;
-#endif
-
-
//============================================================
// PROTOTYPES
@@ -86,10 +81,6 @@ static void dsound_destroy_buffers(void);
void winsound_init(running_machine *machine)
{
-#if LOG_SOUND
- sound_log = fopen("sound.log", "w");
-#endif
-
// if no sound, don't create anything
if (!options_get_bool(mame_options(), OPTION_SOUND))
return;
@@ -117,11 +108,7 @@ static void sound_exit(running_machine *machine)
if (buffer_overflows || buffer_underflows)
mame_printf_verbose("Sound: buffer overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows);
-#if LOG_SOUND
- if (sound_log)
- fprintf(sound_log, "Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows);
- fclose(sound_log);
-#endif
+ LOG(("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows));
}
@@ -289,9 +276,8 @@ static HRESULT dsound_init(running_machine *machine)
stream_buffer_size = (stream_buffer_size / 1024) * 1024;
if (stream_buffer_size < 1024)
stream_buffer_size = 1024;
-#if LOG_SOUND
- fprintf(sound_log, "stream_buffer_size = %d\n", stream_buffer_size);
-#endif
+
+ LOG(("stream_buffer_size = %d\n", stream_buffer_size));
// create the buffers
result = dsound_create_buffers();
diff --git a/src/osd/windows/winalloc.c b/src/osd/windows/winalloc.c
index 536442a22b9..6b7357cbd97 100644
--- a/src/osd/windows/winalloc.c
+++ b/src/osd/windows/winalloc.c
@@ -39,6 +39,12 @@
// set this to 1 to record all mallocs and frees in the logfile
#define LOG_CALLS 0
+#if LOG_CALLS
+#define LOG(x) do { if (LOG_CALLS) logerror x; } while (0)
+void CLIB_DECL logerror(const char *text,...);
+#else
+#define LOG(x)
+#endif
//============================================================
@@ -177,13 +183,11 @@ void *malloc_file_line(size_t size, const char *file, int line)
block_base = (UINT8 *)GlobalAlloc(GMEM_FIXED, size);
}
-#if LOG_CALLS
// logging
if (file != NULL)
- logerror("malloc #%06d size = %d (%s:%d)\n", id, size, file, line);
+ LOG(("malloc #%06d size = %d (%s:%d)\n", id, size, file, line));
else
- logerror("malloc #%06d size = %d\n", id, size);
-#endif // LOG_CALLS
+ LOG(("malloc #%06d size = %d\n", id, size));
return block_base;
}
@@ -344,9 +348,7 @@ void CLIB_DECL free_file_line(void *memory, const char *file, int line)
// free the memory
VirtualFree((UINT8 *)memory - ((size_t)memory & (PAGE_SIZE-1)) - PAGE_SIZE, 0, MEM_RELEASE);
-#if LOG_CALLS
- logerror("free #%06d size = %d\n", entry->id, entry->size);
-#endif // LOG_CALLS
+ LOG(("free #%06d size = %d\n", entry->id, entry->size));
}
else
{
diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c
index bcbed686954..18868115ebb 100644
--- a/src/osd/windows/window.c
+++ b/src/osd/windows/window.c
@@ -183,6 +183,7 @@ static void mtlog_dump(void)
}
#else
void mtlog_add(const char *event) { }
+static void mtlog_dump(void) { }
#endif
@@ -286,9 +287,7 @@ static void winwindow_exit(running_machine *machine)
PostThreadMessage(window_threadid, WM_USER_SELF_TERMINATE, 0, 0);
WaitForSingleObject(window_thread, INFINITE);
-#if (LOG_THREADS)
mtlog_dump();
-#endif
}
// kill the UI pause event