diff --git a/CHANGELOG.md b/CHANGELOG.md index 9721ed427..7681e8143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Retro-Go 1.31.1 (2022-03-08) +- All: Fixed sound on MRGC-G32 + + # Retro-Go 1.31 (2022-02-15) - Launcher: Fixed occasional crash when changing tab - GBC: Fixed high cpu usage / slowdowns diff --git a/handy-go/components/handy/c65c02.h b/handy-go/components/handy/c65c02.h index 2fe3fd65a..755ae0572 100644 --- a/handy-go/components/handy/c65c02.h +++ b/handy-go/components/handy/c65c02.h @@ -243,8 +243,6 @@ class C65C02 // mPC=CPU_PEEKW(NMI_VECTOR); // } - // fprintf(stderr, "cpu update\n"); - if(gSystemIRQ && !mI) { TRACE_CPU1("Update() IRQ taken at PC=%04x",mPC); @@ -1756,9 +1754,7 @@ class C65C02 inline void xILLEGAL(void) { - //char addr[1024]; - //sprintf(addr,"C65C02::Update() - Illegal opcode (%02x) at PC=$%04x.",mOpcode,mPC); - fprintf(stderr, "C65C02::Update() - Illegal opcode (%02x) at PC=$%04x.",mOpcode,mPC); + log_printf("CPU: Illegal opcode $%02x at PC=$%04x.\n", mOpcode, mPC); } private: diff --git a/handy-go/components/handy/cart.cpp b/handy-go/components/handy/cart.cpp index 51f26f16f..277a80931 100644 --- a/handy-go/components/handy/cart.cpp +++ b/handy-go/components/handy/cart.cpp @@ -44,7 +44,6 @@ //#define TRACE_CART -#include #include #include #include @@ -79,14 +78,14 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize) if(mFileHeader.magic[0]!='L' || mFileHeader.magic[1]!='Y' || mFileHeader.magic[2]!='N' || mFileHeader.magic[3]!='X' || mFileHeader.version!=1) { - fprintf(stderr, "Invalid cart (no header?).\nGuessing a ROM layout...\n"); + log_printf("Invalid cart (magic number).\n"); strncpy((char*)&mFileHeader.cartname,"NO HEADER",32); strncpy((char*)&mFileHeader.manufname,"HANDY",16); mFileHeader.page_size_bank0=gamesize>>8;// Hard workaround... } else { headersize=sizeof(LYNX_HEADER); mCRC32=crc32_le(0, gamedata+headersize, gamesize-headersize); - printf("Cart '%s' loaded, CRC32=%08X\n", mFileHeader.cartname, mCRC32); + log_printf("Cart '%s' loaded, CRC32=%08X\n", mFileHeader.cartname, mCRC32); } // As this is a cartridge boot unset the boot address @@ -123,7 +122,7 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize) mCountMask0=0x7ff; break; default: - fprintf(stderr, "Invalid cart (bank0 size).\n"); + log_printf("Invalid cart (bank0 size = %06x).\n", mFileHeader.page_size_bank0); break; } TRACE_CART1("CCart() - Bank0 = $%06x",mMaskBank0); @@ -158,7 +157,7 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize) mCountMask1=0x7ff; break; default: - fprintf(stderr, "Invalid cart (bank1 size).\n"); + log_printf("Invalid cart (bank1 size = %06x).\n", mFileHeader.page_size_bank1); break; } TRACE_CART1("CCart() - Bank1 = $%06x",mMaskBank1); diff --git a/handy-go/components/handy/eeprom.cpp b/handy-go/components/handy/eeprom.cpp index 52b2b9070..4ff42f8ad 100644 --- a/handy-go/components/handy/eeprom.cpp +++ b/handy-go/components/handy/eeprom.cpp @@ -44,7 +44,7 @@ void CEEPROM::Load(void) if(!Available()) return; FILE *fe; if((fe=fopen(filename,"rb"))!=NULL){ - printf("EEPROM LOAD %s\n",filename); + log_printf("EEPROM: Loading from '%s'\n",filename); fread(romdata,1,1024,fe); fclose(fe); } @@ -55,7 +55,7 @@ void CEEPROM::Save(void) if(!Available()) return; FILE *fe; if((fe=fopen(filename,"wb+"))!=NULL){ - printf("EEPROM SAVE %s\n",filename); + log_printf("EEPROM: Saving to '%s'\n",filename); fwrite(romdata,1,Size(),fe); fclose(fe); } @@ -111,55 +111,54 @@ bool CEEPROM::ContextLoad(LSS_FILE *fp) void CEEPROM::SetEEPROMType(UBYTE b) { type=b; - printf("\nEEPROM: "); + const char *type = "none"; switch(b&0x7) { case 1: // 93C46 , 8 bit mode ADDR_MASK = 0x7F; CMD_BITS = 10; ADDR_BITS = 7; - printf("93C46 "); + type = "93C46"; break; case 2: // 93C56 , 8 bit mode ADDR_MASK = 0xFF; CMD_BITS = 12; ADDR_BITS = 9; - printf("93C56 "); + type = "93C56"; break; case 3: // 93C66 , 8 bit mode ADDR_MASK = 0x1FF; CMD_BITS = 12; ADDR_BITS = 9; - printf("93C66 "); + type = "93C66"; break; case 4: // 93C76 , 8 bit mode ADDR_MASK = 0x3FF; CMD_BITS = 14; ADDR_BITS = 11; - printf("93C76 "); + type = "93C76"; break; case 5: // 93C86 , 8 bit mode ADDR_MASK = 0x7FF; CMD_BITS = 14; ADDR_BITS = 11; - printf("93C86 "); + type = "93C86"; break; case 0: // NONE, fallthrou default: ADDR_MASK = 0; CMD_BITS = 1; ADDR_BITS = 1; - printf("none "); break; } if(b&0x80) { // 8 bit access DONE_MASK = 0x100; - printf("8 bit\n"); + log_printf("EEPROM: Type: %s 8bit\n", type); } else { // 16 bit access ADDR_MASK>>=1; CMD_BITS--; ADDR_BITS--; DONE_MASK = 0x10000; - printf("16 bit\n"); + log_printf("EEPROM: Type: %s 16bit\n", type); } } diff --git a/handy-go/components/handy/mikie.cpp b/handy-go/components/handy/mikie.cpp index 1ef75a398..4137f75eb 100644 --- a/handy-go/components/handy/mikie.cpp +++ b/handy-go/components/handy/mikie.cpp @@ -96,15 +96,6 @@ static inline ULONG GetLfsrNext(ULONG current) #endif } -void CMikie::BlowOut(void) -{ - C6502_REGS regs; - mSystem.mCpu->GetRegs(regs); - printf("Runtime Error - System Halted\nCMikie::Poke() - Read/Write to counter clocks at PC=$%04x.\n",regs.PC); - gSystemHalt=TRUE; - abort(); -} - CMikie::CMikie(CSystem& parent, ULONG displayformat, ULONG samplerate) :mSystem(parent) @@ -1573,7 +1564,7 @@ void CMikie::Poke(ULONG addr,UBYTE data) if(!(data&0x02)) { C6502_REGS regs; mSystem.mCpu->GetRegs(regs); - printf("Runtime Alert - System Halted\nCMikie::Poke(SYSCTL1) - Lynx power down occurred at PC=$%04x.\nResetting system.\n",regs.PC); + log_printf("CMikie::Poke(SYSCTL1) - Lynx power down occurred at PC=$%04x.\nResetting system.\n", regs.PC); mSystem.Reset(); gSystemHalt=TRUE; } @@ -1701,7 +1692,7 @@ void CMikie::Poke(ULONG addr,UBYTE data) case 0xFE19+3: mSystem.HLE_BIOS_FE19(); break; case 0xFE4A+3: mSystem.HLE_BIOS_FE4A(); break; case 0xFF80+3: mSystem.HLE_BIOS_FF80(); break; - default: printf("ROM code missing...\n"); + default: log_printf("BIOS: Missing function $%04X\n", mSystem.mCpu->GetPC()); } break; case (GREEN0&0xff): @@ -3023,7 +3014,6 @@ inline void CMikie::Update(void) UpdateSound(); } - // printf("CMikie::Update() - gSystemCycleCount==gNextTimerEvent, system lock likely\n"); // TRACE_MIKIE1("Update() - NextTimerEvent = %012d",gNextTimerEvent); // Update system IRQ status as a result of timer activity diff --git a/handy-go/components/handy/ram.h b/handy-go/components/handy/ram.h index b104f1457..9daf239cf 100644 --- a/handy-go/components/handy/ram.h +++ b/handy-go/components/handy/ram.h @@ -83,7 +83,7 @@ class CRam : public CLynxBase memcpy(&mFileHeader, filememory, sizeof(HOME_HEADER)); if(mFileHeader.magic[0]!='B' || mFileHeader.magic[1]!='S' || mFileHeader.magic[2]!='9' || mFileHeader.magic[3]!='3') { - fprintf(stderr, "Invalid cart.\n"); + log_printf("Invalid cart (header).\n"); } else { #ifndef MSB_FIRST mFileHeader.load_address = mFileHeader.load_address<<8 | mFileHeader.load_address>>8; diff --git a/handy-go/components/handy/susie.cpp b/handy-go/components/handy/susie.cpp index 1da9babe1..a7f99357b 100644 --- a/handy-go/components/handy/susie.cpp +++ b/handy-go/components/handy/susie.cpp @@ -1006,7 +1006,7 @@ ULONG CSusie::PaintSprites(void) // Perform Sprite debugging if required, single step on sprite draw if(gSingleStepModeSprites) { // char message[256]; - //sprintf("CSusie:PaintSprites() - Rendered Sprite %03d\n",sprcount); + //log_printf("CSusie:PaintSprites() - Rendered Sprite %03d\n",sprcount); //SingleStepModeSprites=0; } } else { @@ -1030,7 +1030,7 @@ ULONG CSusie::PaintSprites(void) // Stop the system, otherwise we may just come straight back in..... gSystemHalt=TRUE; // Display warning message - printf("CSusie:PaintSprites(): Single draw sprite limit exceeded (>4096). The SCB is most likely looped back on itself. Reset/Exit is recommended\n"); + log_printf("CSusie:PaintSprites(): Single draw sprite limit exceeded (>4096). The SCB is most likely looped back on itself. Reset/Exit is recommended\n"); // Signal error to the caller return 0; } diff --git a/handy-go/components/handy/susie.h b/handy-go/components/handy/susie.h index 4f5bf9620..ca60fc10c 100644 --- a/handy-go/components/handy/susie.h +++ b/handy-go/components/handy/susie.h @@ -419,7 +419,7 @@ class CSusie : public CLynxBase if(voff>101) { - printf("CSusie::LineInit() Out of bounds (voff)\n"); + log_printf("CSusie::LineInit() Out of bounds (voff)\n"); voff=0; } diff --git a/handy-go/components/handy/system.cpp b/handy-go/components/handy/system.cpp index dfef8f7ae..a2f84a4f4 100644 --- a/handy-go/components/handy/system.cpp +++ b/handy-go/components/handy/system.cpp @@ -146,12 +146,12 @@ CSystem::CSystem(const char* gamefile, long displayformat, long samplerate) filememory=(UBYTE*) new UBYTE[filesize]; if(fread(filememory, 1, filesize,fp)!=filesize) { - fprintf(stderr, "Invalid Cart (filesize).\n"); + log_printf("Invalid cart (filesize).\n"); } fclose(fp); } else { - fprintf(stderr, "Invalid Cart.\n"); + log_printf("Invalid cart (fopen failed).\n"); } // Now try and determine the filetype we have opened @@ -164,10 +164,10 @@ CSystem::CSystem(const char* gamefile, long displayformat, long samplerate) if(!strcmp(&clip[6],"BS93")) mFileType=HANDY_FILETYPE_HOMEBREW; else if(!strcmp(&clip[0],"LYNX")) mFileType=HANDY_FILETYPE_LNX; else if(filesize==128*1024 || filesize==256*1024 || filesize==512*1024) { - fprintf(stderr, "Invalid Cart (type). but 128/256/512k size -> set to RAW and try to load raw rom image\n"); + log_printf("Invalid cart (type). but 128/256/512k size -> set to RAW and try to load raw rom image\n"); mFileType=HANDY_FILETYPE_RAW; } else { - fprintf(stderr, "Invalid Cart (type). -> set to RAW and try to load raw rom image\n"); + log_printf("Invalid cart (type). -> set to RAW and try to load raw rom image\n"); mFileType=HANDY_FILETYPE_RAW; } } @@ -420,10 +420,10 @@ bool CSystem::ContextLoad(LSS_FILE *fp) ULONG checksum; // Read CRC32 and check against the CART for a match lss_read(&checksum,sizeof(ULONG),1,fp); - // if(mCart->CRC32()!=checksum) { - // fprintf(stderr, "[handy]LSS Snapshot CRC does not match the loaded cartridge image, aborting load.\n"); - // return 0; - // } + if(mCart->CRC32()!=checksum) { + log_printf("CSystem::ContextLoad() LSS Snapshot CRC does not match the loaded cartridge image...\n"); + // return 0; + } // Check our block header if(!lss_read(teststr,sizeof(char),20,fp)) status=0; @@ -462,7 +462,7 @@ bool CSystem::ContextLoad(LSS_FILE *fp) gAudioBufferPointer = 0; } else { - fprintf(stderr, "[handy]Not a recognised LSS file\n"); + log_printf("CSystem::ContextLoad() Not a recognised LSS file!\n"); } return status; @@ -475,7 +475,7 @@ void CSystem::DebugTrace(int address) char message[1024+1]; int count=0; - sprintf(message,"%08x - DebugTrace(): ",gSystemCycleCount); + log_printf(message,"%08x - DebugTrace(): ",gSystemCycleCount); count=strlen(message); if(address) { @@ -484,7 +484,7 @@ void CSystem::DebugTrace(int address) char linetext[1024]; // Register dump mCpu->GetRegs(regs); - sprintf(linetext,"PC=$%04x SP=$%02x PS=0x%02x A=0x%02x X=0x%02x Y=0x%02x",regs.PC,regs.SP, regs.PS,regs.A,regs.X,regs.Y); + log_printf(linetext,"PC=$%04x SP=$%02x PS=0x%02x A=0x%02x X=0x%02x Y=0x%02x",regs.PC,regs.SP, regs.PS,regs.A,regs.X,regs.Y); strcat(message,linetext); count=strlen(message); } else { diff --git a/handy-go/components/handy/system.h b/handy-go/components/handy/system.h index ec42ccea3..e09eb5e6b 100644 --- a/handy-go/components/handy/system.h +++ b/handy-go/components/handy/system.h @@ -66,8 +66,6 @@ typedef uint32_t ULONG; #define FALSE false #endif -#include "lynxbase.h" - #define HANDY_SYSTEM_FREQ 16000000 #define HANDY_TIMER_FREQ 20 #define HANDY_AUDIO_SAMPLE_FREQ 24000 // 48000 @@ -139,6 +137,14 @@ extern UBYTE *gPrimaryFrameBuffer; #define lss_write(s, vs, vc, fp) (fwrite(s, vs, vc, fp) > 0) #define lss_printf(fp, str) (fputs(str, fp) >= 0) +// +// Define logging functions +// + +#include +// #define log_printf(x...) printf(x) +#define log_printf(x...) rg_system_log(RG_LOG_USER, NULL, x) + // // Define the interfaces before we start pulling in the classes @@ -185,7 +191,6 @@ class CSystem : public CSystemBase inline void Update(void) { - // fprintf(stderr, "sys update\n"); // // Only update if there is a predicted timer event // @@ -197,7 +202,6 @@ class CSystem : public CSystemBase // Step the processor through 1 instruction // mCpu->Update(); - // fprintf(stderr, "end cpu update\n"); #ifdef _LYNXDBG // Check breakpoint @@ -216,8 +220,6 @@ class CSystem : public CSystemBase { gSystemCycleCount=gNextTimerEvent; } - - // fprintf(stderr, "end sys update\n"); } inline void UpdateFrame(bool draw)