diff --git a/audioSystem.cpp b/audioSystem.cpp index 39aaa95..d86f9b3 100644 --- a/audioSystem.cpp +++ b/audioSystem.cpp @@ -1,13 +1,9 @@ -#include "math.h" #include "audioSystem.h" extern logger glbTheLogger; -std::vector audioVector; -static bool travasing = false; -float buffaPos = 0; - +static std::deque audioQueue; // @@ -18,12 +14,11 @@ DWORD CALLBACK StreamProc(HSTREAM handle, float* buffer, DWORD length, void* use float* paudioInc = (float*)user; - travasing = true; - unsigned int avsize = (unsigned int)audioVector.size(); + const unsigned int avsize = (unsigned int)audioQueue.size(); if (length == 0) return 0; - if (avsize == 0) + if (avsize < 2) { for (unsigned int pos = 0;pos < length / sizeof(float);pos ++) { @@ -33,23 +28,21 @@ DWORD CALLBACK StreamProc(HSTREAM handle, float* buffer, DWORD length, void* use return length; } - float nsamplesAva = avsize - buffaPos; - //glbTheLogger.logMsg("samples available:"+std::to_string(avsize- buffaPos)); + float nsamplesAva = avsize; + //glbTheLogger.logMsg("samples available:"+std::to_string(avsize)); + //glbTheLogger.logMsg("audio inc:"+std::to_string((*paudioInc))); if (nsamplesAva > 15000) (*paudioInc) -= 0.001f; else (*paudioInc) += 0.001f; - //float inc = 1.0; - //inc = (avsize - buffaPos) / (length / sizeof(float)); - //glbTheLogger.logMsg("inc is:" + std::to_string(inc)); - for (unsigned int pos = 0;pos < length / sizeof(float);pos += 2) { - if (buffaPos < avsize) + if (audioQueue.size()>=2) { - buffer[pos] = audioVector[(unsigned int)buffaPos]; - buffer[pos + 1] = audioVector[(unsigned int)buffaPos + 1]; - buffaPos += 2; + buffer[pos] = audioQueue[0]; + audioQueue.pop_front(); + buffer[pos + 1] = audioQueue[0]; + audioQueue.pop_front(); } else { @@ -58,12 +51,8 @@ DWORD CALLBACK StreamProc(HSTREAM handle, float* buffer, DWORD length, void* use //glbTheLogger.logMsg("not enough samples to fill audio buffer"); } } - - //audioVector.clear(); - travasing = false; return length; - //return avsize*sizeof(float); } audioSystem::audioSystem() @@ -98,27 +87,8 @@ audioSystem::audioSystem() void audioSystem::feedAudiobuf(float l, float r) { - audioVector.push_back(l); - audioVector.push_back(r); - - /*float samplesPerFrame = (sampleRate / 60.0) * 2; - DWORD status = BASS_ChannelGetData(stream, NULL, BASS_DATA_AVAILABLE); - if ((status != -1) && (status < samplesPerFrame)) - { - const int dim = audioVector.size(); - if (dim>=samplesPerFrame) - { - glbTheLogger.logMsg("Available samples:" + std::to_string(status)); - glbTheLogger.logMsg("Feeding:" + std::to_string(dim)); - for (unsigned int pos = 0;pos < dim;pos++) - { - tmpbuf[pos] = audioVector[pos]; - } - - BASS_StreamPutData(stream, (void*)tmpbuf, dim); - audioVector.clear(); - } - }*/ + audioQueue.push_back(l); + audioQueue.push_back(r); } audioSystem::~audioSystem() diff --git a/audioSystem.h b/audioSystem.h index edac250..a1ab6fc 100644 --- a/audioSystem.h +++ b/audioSystem.h @@ -2,13 +2,13 @@ #ifndef AUDIOSYSTEM_H #define AUDIOSYSTEM_H +#include #include #include #include #include "bass/bass.h" #include "apu.h" #include "logger.h" -//#include "include/AudioFile.h" class apu; diff --git a/cpu5a22.cpp b/cpu5a22.cpp index 2562a93..49aa85c 100644 --- a/cpu5a22.cpp +++ b/cpu5a22.cpp @@ -6369,7 +6369,7 @@ int cpu5a22::stepOne() unsigned int addr = getDirectPageIndirectX(); doADC(addr); - if (regP.getAccuMemSize()) + if (regP.getAccuMemSize()==0) { cycAdder += 1;; } @@ -6614,6 +6614,24 @@ int cpu5a22::stepOne() cycles = 6 + cycAdder; break; } + case 0xe1: + { + // SBC (dp,X) + int cycAdder = 0; + unsigned int addr = getDirectPageIndirectX(); + + doSBC(addr); + if (regP.getAccuMemSize()==0) + { + cycAdder += 1; + } + + if (regD & 0xff) cycAdder += 1; + + regPC += 2; + cycles = cycAdder + 6; + break; + } default: { // unknown opcode diff --git a/debugger5a22.cpp b/debugger5a22.cpp index 02c7969..846f335 100644 --- a/debugger5a22.cpp +++ b/debugger5a22.cpp @@ -222,6 +222,7 @@ static const debugInfoRec debugInstrData[] = {0xDE,3,"DEC param0,X",Absolute16,false,false,true}, // validatedF {0xdf,4,"CMP param0,X",AbsoluteLong,false,false ,true}, // validatedF {0xE0,2,"CPX param0",Immediate,true,false,true}, // validatedF + {0xe1,2,"SBC (param0,X)",Immediate8,false,false,true}, // validatedF {0xe2,2,"SEP param0",Immediate8,false,false,true}, // validatedF {0xe3,2,"SBC param0,S",Immediate8,false,false,true}, // validatedF {0xe4,2,"CPX param0",Immediate8,false,false,true}, // validatedF diff --git a/imgui.ini b/imgui.ini index 2f769a1..8a6a088 100644 --- a/imgui.ini +++ b/imgui.ini @@ -74,7 +74,7 @@ Size=474,482 Collapsed=1 [Window][Appo and tests window] -Pos=488,5 +Pos=488,4 Size=516,77 [Window][SPC700 Debuggah] @@ -2145,6 +2145,238 @@ Size=700,450 Pos=402,155 Size=700,450 +[Window][Load SNES ROM##filebrowser_342969594608] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_62685361584] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_23569478080] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_463228218880] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_112525750816] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_226893870192] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_685603926928] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_545436577872] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_237269135056] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_1078659101728] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_429361312160] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_850894041952] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_1074911162800] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_281180746960] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_583239904784] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_87649267984] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_15840687232] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_812316209360] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_726854906784] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_828847797376] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_12101530032] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_56766870256] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_231350317312] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_14366584512] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_297054745664] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_766719668352] +Pos=409,173 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_672672887216] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_561643368560] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_755007075488] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_836842140528] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_428428209920] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_114291487648] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_682837782560] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_745186111360] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_279812107088] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_898012015888] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_747011829648] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_320387198800] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_832505427120] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_452730794048] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_74391074208] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_256524530288] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_517532856096] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_63415708400] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_1063550562896] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_1016100795824] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_748309099840] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_612851625616] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_1094003306800] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_798630588336] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_184492470432] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_206899885504] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_9621517360] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_530773292208] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_623062856208] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_1028868190272] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_416224751392] +Pos=402,155 +Size=700,450 + +[Window][Load SNES ROM##filebrowser_771058676256] +Pos=402,155 +Size=700,450 + [Table][0x64418101,3] RefScale=13 Column 0 Width=63 diff --git a/romLoader.cpp b/romLoader.cpp index 891e5bd..5463b7a 100644 --- a/romLoader.cpp +++ b/romLoader.cpp @@ -108,6 +108,11 @@ void romLoader::checkRomType(std::vector* romContents, bool& isHi loadLog.push_back("Header says it's HiROM"); } + // SRAM size + unsigned char sramSize = (*romContents)[0xffd8 + romAdder]; + int iSRAMsize = (1 << sramSize)*1024; + loadLog.push_back("SRAM size:" + std::to_string(iSRAMsize)); + // rom country unsigned char romCountry = (*romContents)[0xffd9+ romAdder]; loadLog.push_back("Standard/Country:" + std::to_string(romCountry));