// Copyright (C) 2003-2008 Dolphin Project. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, version 2.0. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License 2.0 for more details. // A copy of the GPL 2.0 should have been included with the program. // If not, see http://www.gnu.org/licenses/ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ #ifdef _WIN32 // ======================================================================================= // Includes // -------------- #include #include #include // So that we can test if std::string == abc #include #include "Common.h" #include "UCode_AXStructs.h" // they are only in a virtual dir called UCodes AX // ===================== // ======================================================================================= // Declarations and definitions // -------------- // ---------------------------------- // Settings // -------------- #define NUMBER_OF_PBS 64 // Todo: move this to a logging class // ----------------------------------- // Externals // -------------- extern u32 m_addressPBs; float ratioFactor; int globaliSize; short globalpBuffer; u32 gLastBlock; // -------------- // ----------------------------------- // Vectors and other things // -------------- std::vector gloopPos(64); std::vector gsampleEnd(64); std::vector gsamplePos(64); std::vector gratio(64); std::vector gratiohi(64); std::vector gratiolo(64); std::vector gfrac(64); std::vector gcoef(64); // PBSampleRateConverter mixer std::vector gvolume_left(64); std::vector gvolume_right(64); std::vector gmixer_control(64); std::vector gcur_volume(64); std::vector gcur_volume_delta(64); std::vector gaudioFormat(64); std::vector glooping(64); std::vector gsrc_type(64); std::vector gis_stream(64); // loop std::vector gloop1(64); std::vector gloop2(64); std::vector gloop3(64); std::vector gadloop1(64); std::vector gadloop2(64); std::vector gadloop3(64); // updates std::vector gupdates1(64); std::vector gupdates2(64); std::vector gupdates3(64); std::vector gupdates4(64); std::vector gupdates5(64); std::vector gupdates_addr(64); // Other things std::vector Jump(64); // this is 1 or 0 std::vector musicLength(64); std::vector< std::vector > vector1(64, std::vector(100,0)); std::vector numberRunning(64); int j = 0; int k = 0; __int64 l = 0; int iupd = 0; bool iupdonce = false; std::vector viupd(15); // the length of the update frequency bar int vectorLength = 15; // the length of the playback history bar and how long // old blocks are shown std::vector vector62(vectorLength); std::vector vector63(vectorLength); int ReadOutPBs(AXParamBlock * _pPBs, int _num); // ===================== // ======================================================================================= // Main logging function // -------------- void Logging() { // --------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------- // Control how often the screen is updated j++; l++; if (j>1000000) // TODO: make the update frequency adjustable from the logging window { AXParamBlock PBs[NUMBER_OF_PBS]; int numberOfPBs = ReadOutPBs(PBs, NUMBER_OF_PBS); // ======================================================================================= // Vector1 is a vector1[64][100] vector /* Move all items back like this 1 to 2 2 3 3 ... */ // ---------------- for (int i = 0; i < 64; i++) { for (int j = 1; j < vectorLength; j++) { vector1.at(i).at(j-1) = vector1.at(i).at(j); } } // ================= // --------------------------------------------------------------------------------------- // Enter the latest value for (int i = 0; i < numberOfPBs; i++) { vector1.at(i).at(vectorLength-1) = PBs[i].running; } // ----------------- // --------------------------------------------------------------------------------------- // Count how many blocks we have running now int jj = 0; for (int i = 0; i < 64; i++) { for (int j = 0; j < vectorLength-1; j++) { if (vector1.at(i).at(j) == 1) { jj++; } numberRunning.at(i) = jj; } } // -------------- // --------------------------------------------------------------------------------------- // Write the first row char buffer [1000] = ""; std::string sbuff; //sbuff = sbuff + " Nr | | frac ratio | old new \n"; // 5 sbuff = sbuff + " Nr pos / end lpos | voll volr curv vold mix | isl[pre yn1 yn2] iss | frac ratio[hi lo] | 1 2 3 4 5\n"; // -------------- // --------------------------------------------------------------------------------------- // Read out values for all blocks for (int i = 0; i < numberOfPBs; i++) { if (numberRunning.at(i) > 0) { // ======================================================================================= // Write the playback bar // ------------- for (int j = 0; j < vectorLength; j++) { if(vector1.at(i).at(j) == 0) { sbuff = sbuff + " "; } else { sprintf(buffer, "%c", 177); sbuff = sbuff + buffer; strcpy(buffer, ""); } } // ============== // ================================================================================================ int sampleJump; int loopJump; //if (PBs[i].running && PBs[i].adpcm_loop_info.yn1 && PBs[i].mixer.volume_left) if (true) { // --------------------------------------------------------------------------------------- // AXPB base //int running = pb.running; gcoef[i] = PBs[i].unknown1; sampleJump = ((PBs[i].audio_addr.cur_addr_hi << 16) | PBs[i].audio_addr.cur_addr_lo) - gsamplePos[i]; loopJump = ((PBs[i].audio_addr.loop_addr_hi << 16) | PBs[i].audio_addr.loop_addr_lo) - gloopPos[i]; gloopPos[i] = (PBs[i].audio_addr.loop_addr_hi << 16) | PBs[i].audio_addr.loop_addr_lo; gsampleEnd[i] = (PBs[i].audio_addr.end_addr_hi << 16) | PBs[i].audio_addr.end_addr_lo; gsamplePos[i] = (PBs[i].audio_addr.cur_addr_hi << 16) | PBs[i].audio_addr.cur_addr_lo; // PBSampleRateConverter src gratio[i] = (u32)(((PBs[i].src.ratio_hi << 16) + PBs[i].src.ratio_lo) * ratioFactor); gratiohi[i] = PBs[i].src.ratio_hi; gratiolo[i] = PBs[i].src.ratio_lo; gfrac[i] = PBs[i].src.cur_addr_frac; // adpcm_loop_info gadloop1[i] = PBs[i].adpcm.pred_scale; gadloop2[i] = PBs[i].adpcm.yn1; gadloop3[i] = PBs[i].adpcm.yn2; gloop1[i] = PBs[i].adpcm_loop_info.pred_scale; gloop2[i] = PBs[i].adpcm_loop_info.yn1; gloop3[i] = PBs[i].adpcm_loop_info.yn2; // updates gupdates1[i] = PBs[i].updates.num_updates[0]; gupdates2[i] = PBs[i].updates.num_updates[1]; gupdates3[i] = PBs[i].updates.num_updates[2]; gupdates4[i] = PBs[i].updates.num_updates[3]; gupdates5[i] = PBs[i].updates.num_updates[4]; gupdates_addr[i] = (PBs[i].updates.data_hi << 16) | PBs[i].updates.data_lo; gaudioFormat[i] = PBs[i].audio_addr.sample_format; glooping[i] = PBs[i].audio_addr.looping; gsrc_type[i] = PBs[i].src_type; gis_stream[i] = PBs[i].is_stream; // mixer gvolume_left[i] = PBs[i].mixer.volume_left; gvolume_right[i] = PBs[i].mixer.volume_right; gmixer_control[i] = PBs[i].mixer_control; gcur_volume[i] = PBs[i].vol_env.cur_volume; gcur_volume_delta[i] = PBs[i].vol_env.cur_volume_delta; // other stuff Jump[i] = (gfrac[i] >> 16); // This is 1 or 0 musicLength[i] = gsampleEnd[i] - gloopPos[i]; } // ================================================================================================ // ======================================================================================= // PRESETS // --------------------------------------------------------------------------------------- /* /" Nr pos / end lpos | voll volr curv vold mix | isl[pre yn1 yn2] iss | frac ratio[hi lo] | 1 2 3 4 5\n"; "---------------|00 12341234/12341234 12341234 | 00000 00000 00000 0000 00000 | 0[000 00000 00000] 0 | 00000 00000[0 00000] | */ sprintf(buffer,"%c%i %08i/%08i %08i | %05i %05i %05i %04i %05i | %i[%03i %05i %05i] %i | %05i %05i[%i %05i] | %i %i %i %i %i", 223, i, gsamplePos[i], gsampleEnd[i], gloopPos[i], gvolume_left[i], gvolume_right[i], gcur_volume[i], gcur_volume_delta[i], gmixer_control[i], glooping[i], gloop1[i], gloop2[i], gloop3[i], gis_stream[i], gfrac[i], gratio[i], gratiohi[i], gratiolo[i], gupdates1[i], gupdates2[i], gupdates3[i], gupdates4[i], gupdates5[i] ); // ======================================================================================= // write a new line sbuff = sbuff + buffer; strcpy(buffer, ""); sbuff = sbuff + "\n"; } // end of if (true) } // end of big loop - for (int i = 0; i < numberOfPBs; i++) // ======================================================================================= // Write global values sprintf(buffer, "\nParameter blocks span from %08x | to %08x | distance %i %i\n", m_addressPBs, gLastBlock, (gLastBlock-m_addressPBs), (gLastBlock-m_addressPBs) / 192); sbuff = sbuff + buffer; strcpy(buffer, ""); // ============== // ======================================================================================= // Show update frequency // --------------- sbuff = sbuff + "\n"; if(!iupdonce) { /* for (int i = 0; i < 10; i++) { viupd.at(i) == 0; } */ viupd.at(0) = 1; viupd.at(1) = 1; viupd.at(2) = 1; iupdonce = true; } for (int i = 0; i < (int)viupd.size(); i++) // 0, 1,..., 9 { if (i < (int)viupd.size()-1) { viupd.at(viupd.size()-i-1) = viupd.at(viupd.size()-i-2); // move all forward } else { viupd.at(0) = viupd.at(viupd.size()-1); } // Correction if (viupd.at(viupd.size()-3) == 1 && viupd.at(viupd.size()-2) == 1 && viupd.at(viupd.size()-1) == 1) { viupd.at(0) = 0; } if(viupd.at(0) == 0 && viupd.at(1) == 1 && viupd.at(2) == 1 && viupd.at(3) == 0) { viupd.at(0) = 1; } } for (int i = 0; i < (int)viupd.size(); i++) { if(viupd.at(i) == 0) sbuff = sbuff + " "; else sbuff = sbuff + "."; } // ================ // ======================================================================================= // Print // --------------- // Console::ClearScreen(); INFO_LOG(DSPHLE, "%s", sbuff.c_str()); sbuff.clear(); strcpy(buffer, ""); // --------------- k=0; j=0; // --------------- } // --------------------------------------------------------------------------------------- } // ======================================================================================= #endif