maple: use new logging

This commit is contained in:
Flyinghead 2019-06-30 23:38:58 +02:00
parent fcc6fd784c
commit a31f573c69
2 changed files with 62 additions and 68 deletions

View File

@ -13,18 +13,7 @@
#include "deps/zlib/zlib.h"
#include "deps/xxhash/xxhash.h"
#if _ANDROID
#include <android/log.h>
#include <jni.h>
#else
#define LOGW printf
#define LOGI printf
#endif
#ifndef RELEASE
#define LOGJVS(...) LOGI(__VA_ARGS__)
#else
#define LOGJVS(...)
#endif
#define LOGJVS(...) DEBUG_LOG(JVS, __VA_ARGS__)
#define SAVE_EEPROM 1
@ -385,7 +374,7 @@ struct maple_sega_vmu: maple_base
// creates an empty VMU
bool init_emptyvmu()
{
printf("Initialising empty VMU...\n");
INFO_LOG(MAPLE, "Initialising empty VMU...");
uLongf dec_sz = sizeof(flash_data);
int rv = uncompress(flash_data, &dec_sz, vmu_default, sizeof(vmu_default));
@ -421,24 +410,24 @@ struct maple_sega_vmu: maple_base
file = fopen(apath.c_str(), "rb+");
if (!file)
{
printf("Unable to open VMU save file \"%s\", creating new file\n",apath.c_str());
INFO_LOG(MAPLE, "Unable to open VMU save file \"%s\", creating new file", apath.c_str());
file = fopen(apath.c_str(), "wb");
if (file) {
if (!init_emptyvmu())
printf("Failed to initialize an empty VMU, you should reformat it using the BIOS\n");
INFO_LOG(MAPLE, "Failed to initialize an empty VMU, you should reformat it using the BIOS");
fwrite(flash_data, sizeof(flash_data), 1, file);
fseek(file, 0, SEEK_SET);
}
else
{
printf("Unable to create VMU!\n");
INFO_LOG(MAPLE, "Unable to create VMU!");
}
}
if (!file)
{
printf("Failed to create VMU save file \"%s\"\n",apath.c_str());
INFO_LOG(MAPLE, "Failed to create VMU save file \"%s\"", apath.c_str());
}
else
{
@ -462,12 +451,12 @@ struct maple_sega_vmu: maple_base
fseek(file, 0, SEEK_SET);
}
else {
printf("Unable to create VMU!\n");
INFO_LOG(MAPLE, "Unable to create VMU!");
}
}
else
{
printf("Failed to initialize an empty VMU, you should reformat it using the BIOS\n");
INFO_LOG(MAPLE, "Failed to initialize an empty VMU, you should reformat it using the BIOS");
}
}
@ -534,7 +523,7 @@ struct maple_sega_vmu: maple_base
u32 pt=r32();
if (pt!=0)
{
printf("VMU: MDCF_GetMediaInfo -> bad input |%08X|, returning MDRE_UnknownCmd\n",pt);
INFO_LOG(MAPLE, "VMU: MDCF_GetMediaInfo -> bad input |%08X|, returning MDRE_UnknownCmd", pt);
return MDRE_UnknownCmd;
}
else
@ -552,7 +541,7 @@ struct maple_sega_vmu: maple_base
break;
default:
printf("VMU: MDCF_GetMediaInfo -> Bad function used |%08X|, returning -2\n",function);
INFO_LOG(MAPLE, "VMU: MDCF_GetMediaInfo -> Bad function used |%08X|, returning -2", function);
return MDRE_UnknownFunction;//bad function
}
}
@ -572,8 +561,8 @@ struct maple_sega_vmu: maple_base
if (Block>255)
{
printf("Block read : %d\n",Block);
printf("BLOCK READ ERROR\n");
DEBUG_LOG(MAPLE, "Block read : %d", Block);
DEBUG_LOG(MAPLE, "BLOCK READ ERROR");
Block&=255;
}
wptr(flash_data+Block*512,512);
@ -596,7 +585,7 @@ struct maple_sega_vmu: maple_base
{
if (r32()!=0)
{
printf("VMU: Block read: MFID_3_Clock : invalid params \n");
INFO_LOG(MAPLE, "VMU: Block read: MFID_3_Clock : invalid params");
return MDRE_TransmitAgain; //invalid params
}
else
@ -620,7 +609,13 @@ struct maple_sega_vmu: maple_base
w8(timenow->tm_sec);
w8(0);
printf("VMU: CLOCK Read-> datetime is %04d/%02d/%02d ~ %02d:%02d:%02d!\n",timebuf[0]+timebuf[1]*256,timebuf[2],timebuf[3],timebuf[4],timebuf[5],timebuf[6]);
DEBUG_LOG(MAPLE, "VMU: CLOCK Read-> datetime is %04d/%02d/%02d ~ %02d:%02d:%02d!",
timebuf[0] + timebuf[1] * 256,
timebuf[2],
timebuf[3],
timebuf[4],
timebuf[5],
timebuf[6]);
return MDRS_DataTransfer;//transfer reply ...
}
@ -628,7 +623,7 @@ struct maple_sega_vmu: maple_base
break;
default:
printf("VMU: cmd MDCF_BlockRead -> Bad function |%08X| used, returning -2\n",function);
INFO_LOG(MAPLE, "VMU: cmd MDCF_BlockRead -> Bad function |%08X| used, returning -2", function);
return MDRE_UnknownFunction;//bad function
}
}
@ -655,7 +650,7 @@ struct maple_sega_vmu: maple_base
}
else
{
printf("Failed to save VMU %s data\n",logical_port);
INFO_LOG(MAPLE, "Failed to save VMU %s data", logical_port);
}
return MDRS_DeviceReply;//just ko
}
@ -746,7 +741,8 @@ struct maple_sega_vmu: maple_base
{
u8 timebuf[8];
rptr(timebuf,8);
printf("VMU: CLOCK Write-> datetime is %04d/%02d/%02d ~ %02d:%02d:%02d! Nothing set tho ...\n",timebuf[0]+timebuf[1]*256,timebuf[2],timebuf[3],timebuf[4],timebuf[5],timebuf[6]);
DEBUG_LOG(MAPLE, "VMU: CLOCK Write-> datetime is %04d/%02d/%02d ~ %02d:%02d:%02d! Nothing set tho ...",
timebuf[0]+timebuf[1]*256,timebuf[2],timebuf[3],timebuf[4],timebuf[5],timebuf[6]);
return MDRS_DeviceReply;//ok !
}
}
@ -754,7 +750,7 @@ struct maple_sega_vmu: maple_base
default:
{
printf("VMU: command MDCF_BlockWrite -> Bad function used, returning MDRE_UnknownFunction\n");
INFO_LOG(MAPLE, "VMU: command MDCF_BlockWrite -> Bad function used, returning MDRE_UnknownFunction");
return MDRE_UnknownFunction;//bad function
}
}
@ -773,7 +769,7 @@ struct maple_sega_vmu: maple_base
u32 bp=r32();
if (bp)
{
printf("BEEP : %08X\n",bp);
INFO_LOG(MAPLE, "BEEP : %08X", bp);
}
return MDRS_DeviceReply;//just ko
}
@ -781,7 +777,7 @@ struct maple_sega_vmu: maple_base
default:
{
printf("VMU: command MDCF_SetCondition -> Bad function used, returning MDRE_UnknownFunction\n");
INFO_LOG(MAPLE, "VMU: command MDCF_SetCondition -> Bad function used, returning MDRE_UnknownFunction");
return MDRE_UnknownFunction;//bad function
}
break;
@ -790,7 +786,7 @@ struct maple_sega_vmu: maple_base
default:
//printf("Unknown MAPLE COMMAND %d\n",cmd);
DEBUG_LOG(MAPLE, "Unknown MAPLE COMMAND %d", cmd);
return MDRE_UnknownCmd;
}
}
@ -829,7 +825,7 @@ struct maple_microphone: maple_base
switch (cmd)
{
case MDC_DeviceRequest:
LOGI("maple_microphone::dma MDC_DeviceRequest\n");
DEBUG_LOG(MAPLE, "maple_microphone::dma MDC_DeviceRequest");
//this was copied from the controller case with just the id and name replaced!
//caps
@ -864,7 +860,7 @@ struct maple_microphone: maple_base
case MDCF_GetCondition:
{
LOGI("maple_microphone::dma MDCF_GetCondition\n");
DEBUG_LOG(MAPLE, "maple_microphone::dma MDCF_GetCondition");
//this was copied from the controller case with just the id replaced!
//PlainJoystickState pjs;
@ -901,7 +897,7 @@ struct maple_microphone: maple_base
case MDC_DeviceReset:
//uhhh do nothing?
LOGI("maple_microphone::dma MDC_DeviceReset\n");
DEBUG_LOG(MAPLE, "maple_microphone::dma MDC_DeviceReset");
return MDRS_DeviceReply;
case MDCF_MICControl:
@ -964,29 +960,29 @@ struct maple_microphone: maple_base
return MDRS_DataTransfer;
}
case 0x02:
LOGI("maple_microphone::dma MDCF_MICControl toggle recording %#010x\n",secondword);
DEBUG_LOG(MAPLE, "maple_microphone::dma MDCF_MICControl toggle recording %#010x", secondword);
return MDRS_DeviceReply;
case 0x03:
LOGI("maple_microphone::dma MDCF_MICControl set gain %#010x\n",secondword);
DEBUG_LOG(MAPLE, "maple_microphone::dma MDCF_MICControl set gain %#010x", secondword);
return MDRS_DeviceReply;
case MDRE_TransmitAgain:
LOGW("maple_microphone::dma MDCF_MICControl MDRE_TransmitAgain\n");
WARN_LOG(MAPLE, "maple_microphone::dma MDCF_MICControl MDRE_TransmitAgain");
//apparently this doesnt matter
//wptr(micdata, SIZE_OF_MIC_DATA);
return MDRS_DeviceReply;//MDRS_DataTransfer;
default:
LOGW("maple_microphone::dma UNHANDLED secondword %#010x\n",secondword);
INFO_LOG(MAPLE, "maple_microphone::dma UNHANDLED secondword %#010x", secondword);
return MDRE_UnknownFunction;
}
}
default:
LOGW("maple_microphone::dma UNHANDLED function %#010x\n",function);
INFO_LOG(MAPLE, "maple_microphone::dma UNHANDLED function %#010x", function);
return MDRE_UnknownFunction;
}
}
default:
LOGW("maple_microphone::dma UNHANDLED MAPLE COMMAND %d\n",cmd);
INFO_LOG(MAPLE, "maple_microphone::dma UNHANDLED MAPLE COMMAND %d", cmd);
return MDRE_UnknownCmd;
}
}
@ -1121,7 +1117,7 @@ struct maple_sega_purupuru : maple_base
return MDRS_DeviceReply;
default:
//printf("UNKOWN MAPLE COMMAND %d\n",cmd);
INFO_LOG(MAPLE, "UNKOWN MAPLE COMMAND %d", cmd);
return MDRE_UnknownCmd;
}
}
@ -1192,7 +1188,7 @@ struct maple_keyboard : maple_base
return MDRS_DataTransfer;
default:
//printf("Keyboard: unknown MAPLE COMMAND %d\n", cmd);
DEBUG_LOG(MAPLE, "Keyboard: unknown MAPLE COMMAND %d", cmd);
return MDRE_UnknownCmd;
}
}
@ -1299,7 +1295,7 @@ struct maple_mouse : maple_base
return MDRS_DataTransfer;
default:
//printf("Mouse: unknown MAPLE COMMAND %d\n", cmd);
DEBUG_LOG(MAPLE, "Mouse: unknown MAPLE COMMAND %d", cmd);
return MDRE_UnknownCmd;
}
}
@ -1379,7 +1375,7 @@ struct maple_lightgun : maple_base
return MDRS_DataTransfer;
default:
//printf("Light gun: unknown MAPLE COMMAND %d\n", cmd);
DEBUG_LOG(MAPLE, "Light gun: unknown MAPLE COMMAND %d", cmd);
return MDRE_UnknownCmd;
}
}
@ -1851,7 +1847,7 @@ struct maple_naomi_jamma : maple_sega_controller
case 0x13: // Store repeated request
if (len > 0 && node_id > 0 && node_id <= 0x1f)
{
printf("JVS node %d: Storing %d cmd bytes\n", node_id, len);
INFO_LOG(MAPLE, "JVS node %d: Storing %d cmd bytes", node_id, len);
jvs_repeat_request[node_id - 1][0] = len;
memcpy(&jvs_repeat_request[node_id - 1][1], cmd, len);
}
@ -1956,7 +1952,7 @@ struct maple_naomi_jamma : maple_sega_controller
{
int address = dma_buffer_in[1];
int size = dma_buffer_in[2];
//printf("EEprom write %08X %08X\n",address,size);
DEBUG_LOG(MAPLE, "EEprom write %08X %08X\n", address, size);
//printState(Command,buffer_in,buffer_in_len);
memcpy(EEPROM + address, dma_buffer_in + 4, size);
@ -1967,10 +1963,10 @@ struct maple_naomi_jamma : maple_sega_controller
{
fwrite(EEPROM, 1, 0x80, f);
fclose(f);
printf("Saved EEPROM to %s\n", eeprom_file.c_str());
INFO_LOG(MAPLE, "Saved EEPROM to %s", eeprom_file.c_str());
}
else
printf("EEPROM SAVE FAILED to %s\n", eeprom_file.c_str());
WARN_LOG(MAPLE, "EEPROM SAVE FAILED to %s", eeprom_file.c_str());
#endif
w8(MDRS_JVSReply);
w8(0x00);
@ -1994,15 +1990,15 @@ struct maple_naomi_jamma : maple_sega_controller
{
fread(EEPROM, 1, 0x80, f);
fclose(f);
printf("Loaded EEPROM from %s\n", eeprom_file.c_str());
DEBUG_LOG(MAPLE, "Loaded EEPROM from %s", eeprom_file.c_str());
}
else if (naomi_default_eeprom != NULL)
{
printf("Using default EEPROM file\n");
DEBUG_LOG(MAPLE, "Using default EEPROM file");
memcpy(EEPROM, naomi_default_eeprom, 0x80);
}
else
printf("EEPROM file not found at %s and no default found\n", eeprom_file.c_str());
DEBUG_LOG(MAPLE, "EEPROM file not found at %s and no default found", eeprom_file.c_str());
}
#endif
//printf("EEprom READ\n");
@ -2057,7 +2053,7 @@ struct maple_naomi_jamma : maple_sega_controller
break;
default:
printf("JVS: Unknown 0x86 sub-command %x\n", subcode);
INFO_LOG(MAPLE, "JVS: Unknown 0x86 sub-command %x", subcode);
w8(MDRE_UnknownCmd);
w8(0x00);
w8(0x20);
@ -2115,7 +2111,7 @@ struct maple_naomi_jamma : maple_sega_controller
if (fw_dump == NULL)
{
fw_dump = fopen(filename, "w");
printf("Saving JVS firmware to %s\n", filename);
INFO_LOG(MAPLE, "Saving JVS firmware to %s", filename);
break;
}
}
@ -2194,7 +2190,7 @@ struct maple_naomi_jamma : maple_sega_controller
break;
default:
//printf("Unknown Maple command %x\n", cmd);
INFO_LOG(MAPLE, "Unknown Maple command %x", cmd);
w8(MDRE_UnknownCmd);
w8(0x00);
w8(0x00);
@ -2573,7 +2569,7 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
break;
default:
printf("JVS: Unknown input type %x\n", buffer_in[cmdi]);
INFO_LOG(MAPLE, "JVS: Unknown input type %x", buffer_in[cmdi]);
JVS_OUT(2); // report byte: command error
cmdi = length_in; // Ignore subsequent commands
break;
@ -2583,7 +2579,7 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
}
else
{
printf("JVS: Unknown JVS command %x\n", jvs_cmd);
INFO_LOG(MAPLE, "JVS: Unknown JVS command %x", jvs_cmd);
JVS_OUT(2); // Unknown command
}
break;

View File

@ -52,11 +52,11 @@ void maple_vblank()
{
if (maple_ddt_pending_reset)
{
//printf("DDT vblank ; reset pending\n");
DEBUG_LOG(MAPLE, "DDT vblank ; reset pending");
}
else
{
//printf("DDT vblank\n");
DEBUG_LOG(MAPLE, "DDT vblank");
SB_MDST = 1;
maple_DoDma();
SB_MDST = 0;
@ -98,7 +98,7 @@ void maple_SB_MDEN_Write(u32 addr, u32 data)
if ((data & 0x1)==0 && SB_MDST)
{
printf("Maple DMA abort ?\n");
INFO_LOG(MAPLE, "Maple DMA abort ?");
}
}
@ -122,9 +122,7 @@ void maple_DoDma()
verify(SB_MDEN &1)
verify(SB_MDST &1)
#if debug_maple
printf("Maple: DoMapleDma SB_MDSTAR=%x\n", SB_MDSTAR);
#endif
DEBUG_LOG(MAPLE, "Maple: DoMapleDma SB_MDSTAR=%x", SB_MDSTAR);
u32 addr = SB_MDSTAR;
u32 xfer_count=0;
bool last = false;
@ -147,7 +145,7 @@ void maple_DoDma()
{
if (!IsOnSh4Ram(header_2))
{
printf("MAPLE ERROR : DESTINATION NOT ON SH4 RAM 0x%X\n",header_2);
INFO_LOG(MAPLE, "MAPLE ERROR : DESTINATION NOT ON SH4 RAM 0x%X", header_2);
header_2&=0xFFFFFF;
header_2|=(3<<26);
}
@ -157,7 +155,7 @@ void maple_DoDma()
u32* p_data =(u32*) GetMemPtr(addr + 8,(plen)*sizeof(u32));
if (p_data == NULL)
{
printf("MAPLE ERROR : INVALID SB_MDSTAR value 0x%X\n", addr);
INFO_LOG(MAPLE, "MAPLE ERROR : INVALID SB_MDSTAR value 0x%X", addr);
SB_MDST=0;
return;
}
@ -183,7 +181,7 @@ void maple_DoDma()
else
{
if (port != 5 && command != 1)
printf("MAPLE: Unknown device bus %d port %d cmd %d\n", bus, port, command);
INFO_LOG(MAPLE, "MAPLE: Unknown device bus %d port %d cmd %d", bus, port, command);
outlen=4;
p_out[0]=0xFFFFFFFF;
}
@ -216,7 +214,7 @@ void maple_DoDma()
break;
default:
printf("MAPLE: Unknown maple_op == %d length %d\n", maple_op, plen * 4);
INFO_LOG(MAPLE, "MAPLE: Unknown maple_op == %d length %d", maple_op, plen * 4);
addr += 1 * 4;
}
}
@ -234,7 +232,7 @@ int maple_schd(int tag, int c, int j)
}
else
{
printf("WARNING: MAPLE DMA ABORT\n");
INFO_LOG(MAPLE, "WARNING: MAPLE DMA ABORT");
SB_MDST=0; //I really wonder what this means, can the DMA be continued ?
}