Skip to content

Commit

Permalink
clang-format update of MCS-04 Analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus10110 committed Oct 9, 2024
1 parent aaf3277 commit 91426d1
Show file tree
Hide file tree
Showing 10 changed files with 745 additions and 724 deletions.
557 changes: 283 additions & 274 deletions src/MCS04Analyzer.cpp

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions src/MCS04Analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@

class ANALYZER_EXPORT MCS04Analyzer : public Analyzer2
{
public:
MCS04Analyzer();
virtual ~MCS04Analyzer();
public:
MCS04Analyzer();
virtual ~MCS04Analyzer();

virtual void SetupResults();
virtual void WorkerThread();
virtual void SetupResults();
virtual void WorkerThread();

virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels );
virtual U32 GetMinimumSampleRateHz();
virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels );
virtual U32 GetMinimumSampleRateHz();

virtual const char* GetAnalyzerName() const;
virtual bool NeedsRerun();
virtual const char* GetAnalyzerName() const;
virtual bool NeedsRerun();

protected: //vars
MCS04AnalyzerSettings mSettings;
std::unique_ptr<MCS04AnalyzerResults> mResults;
AnalyzerChannelData *mData[4], *mClk1, *mClk2, *mSync;
protected: // vars
MCS04AnalyzerSettings mSettings;
std::unique_ptr<MCS04AnalyzerResults> mResults;
AnalyzerChannelData *mData[ 4 ], *mClk1, *mClk2, *mSync;

MCS04SimulationDataGenerator mSimulationDataGenerator;
bool mSimulationInitilized;
MCS04SimulationDataGenerator mSimulationDataGenerator;
bool mSimulationInitilized;

//Serial analysis vars:
U32 mSampleRateHz;
U32 mStartOfStopBitOffset;
U32 mEndOfStopBitOffset;
// Serial analysis vars:
U32 mSampleRateHz;
U32 mStartOfStopBitOffset;
U32 mEndOfStopBitOffset;

private:
unsigned readBus(U64 at);
private:
unsigned readBus( U64 at );
};

extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer( );
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer();
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer );

#endif //MCS04_ANALYZER_H
#endif // MCS04_ANALYZER_H
201 changes: 101 additions & 100 deletions src/MCS04AnalyzerResults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <fstream>

MCS04AnalyzerResults::MCS04AnalyzerResults( MCS04Analyzer* analyzer, MCS04AnalyzerSettings* settings )
: AnalyzerResults(),
mSettings( settings ),
mAnalyzer( analyzer )
: AnalyzerResults(), mSettings( settings ), mAnalyzer( analyzer )
{
}

Expand All @@ -20,121 +18,124 @@ MCS04AnalyzerResults::~MCS04AnalyzerResults()

void MCS04AnalyzerResults::GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base )
{
ClearResultStrings();
Frame frame = GetFrame( frame_index );
union MCS4data data = {.mData1 = frame.mData1, };
char reg_str[4], number_str[64];

ClearResultStrings();

if (channel == mSettings->mBusClk2) { //CLK2 shows bus phase, 1-based (0 means unknown/invalid)

static const char *busPhaseNames[] = {
[MCS4busPhaseA1] = "A1",
[MCS4busPhaseA2] = "A2",
[MCS4busPhaseA3] = "A3",
[MCS4busPhaseM1] = "M1",
[MCS4busPhaseM2] = "M2",
[MCS4busPhaseX1] = "X1",
[MCS4busPhaseX2] = "X2",
[MCS4busPhaseX3] = "X3",
};
const char *nm = data.busPhase < sizeof(busPhaseNames) / sizeof(*busPhaseNames) ? busPhaseNames[data.busPhase] : NULL;

AddResultString( nm ? nm : "<BUS PHASE INVALID>" );
}
else if (channel == mSettings->mBusBit0) { //D0 always shows current 4-bit value

AnalyzerHelpers::GetNumberString( data.busVal, display_base, 4, number_str, sizeof(number_str) );
AddResultString( number_str );
}
else if (channel == mSettings->mBusBit1){ //D1 shows full address/value

if (data.busPhase == MCS4busPhaseA3) {
AnalyzerHelpers::GetNumberString( data.romAddr, display_base, 12, number_str, sizeof(number_str) );
AddResultString( "ROM addr ", number_str );
AddResultString( number_str ); //shorter string variant
}
else if (data.busPhase == MCS4busPhaseM2) {

AnalyzerHelpers::GetNumberString( data.instrVal, display_base, 8, number_str, sizeof(number_str) );
AddResultString( "ROM val ", number_str );
AddResultString( number_str ); //shorter string variant
}
}
else if (channel == mSettings->mBusBit2) {

if (data.busPhase == MCS4busPhaseM2) { //D2 shows disassembly, if valid and data flow

char disasmLong[64] = {}, disasmMedium[64] = {}, disasmShort[64] = {};

mcs04disasm(disasmLong, disasmMedium, disasmShort, (enum MCS4prevInstrState)data.prevInstrState, data.prevInstrOPA, data.romAddr, data.instrVal, mSettings->m4040, display_base);
if (*disasmLong)
AddResultString( disasmLong );
if (*disasmMedium)
AddResultString( disasmMedium );
if (*disasmShort)
AddResultString( disasmShort );
}
else if (data.busPhase == MCS4busPhaseX3 && data.prevInstrState == MCS4prevInstrNormal) { //show effective values on he bus

switch (data.instrVal & 0xf9) {
case 0x21:
case 0x29: //SRC

AnalyzerHelpers::GetNumberString( data.busValAtX2 * 16 + data.busVal, display_base, 8, number_str, sizeof(number_str) );
AddResultString( "(adr ", number_str, ")" );
AddResultString( "(", number_str, ")" );
AddResultString( number_str ); //shorter string variant
break;

case 0xe0:
case 0xe1: //mem write
AnalyzerHelpers::GetNumberString( data.busValAtX2, display_base, 4, number_str, sizeof(number_str) );
AddResultString( "(wr ", number_str, ")" );
AddResultString( "(", number_str, ")" );
AddResultString( number_str ); //shorter string variant
break;

case 0xe8:
case 0xe9:
AnalyzerHelpers::GetNumberString( data.busValAtX2, display_base, 4, number_str, sizeof(number_str) );
AddResultString( "(rd ", number_str, ")" );
AddResultString( "(", number_str, ")" );
AddResultString( number_str ); //shorter string variant
break;
}
}
}
ClearResultStrings();
Frame frame = GetFrame( frame_index );
union MCS4data data = {
.mData1 = frame.mData1,
};
char reg_str[ 4 ], number_str[ 64 ];

ClearResultStrings();

if( channel == mSettings->mBusClk2 )
{ // CLK2 shows bus phase, 1-based (0 means unknown/invalid)

static const char* busPhaseNames[] = {
[MCS4busPhaseA1] = "A1", [MCS4busPhaseA2] = "A2", [MCS4busPhaseA3] = "A3", [MCS4busPhaseM1] = "M1",
[MCS4busPhaseM2] = "M2", [MCS4busPhaseX1] = "X1", [MCS4busPhaseX2] = "X2", [MCS4busPhaseX3] = "X3",
};
const char* nm = data.busPhase < sizeof( busPhaseNames ) / sizeof( *busPhaseNames ) ? busPhaseNames[ data.busPhase ] : NULL;

AddResultString( nm ? nm : "<BUS PHASE INVALID>" );
}
else if( channel == mSettings->mBusBit0 )
{ // D0 always shows current 4-bit value

AnalyzerHelpers::GetNumberString( data.busVal, display_base, 4, number_str, sizeof( number_str ) );
AddResultString( number_str );
}
else if( channel == mSettings->mBusBit1 )
{ // D1 shows full address/value

if( data.busPhase == MCS4busPhaseA3 )
{
AnalyzerHelpers::GetNumberString( data.romAddr, display_base, 12, number_str, sizeof( number_str ) );
AddResultString( "ROM addr ", number_str );
AddResultString( number_str ); // shorter string variant
}
else if( data.busPhase == MCS4busPhaseM2 )
{
AnalyzerHelpers::GetNumberString( data.instrVal, display_base, 8, number_str, sizeof( number_str ) );
AddResultString( "ROM val ", number_str );
AddResultString( number_str ); // shorter string variant
}
}
else if( channel == mSettings->mBusBit2 )
{
if( data.busPhase == MCS4busPhaseM2 )
{ // D2 shows disassembly, if valid and data flow

char disasmLong[ 64 ] = {}, disasmMedium[ 64 ] = {}, disasmShort[ 64 ] = {};

mcs04disasm( disasmLong, disasmMedium, disasmShort, ( enum MCS4prevInstrState )data.prevInstrState, data.prevInstrOPA,
data.romAddr, data.instrVal, mSettings->m4040, display_base );
if( *disasmLong )
AddResultString( disasmLong );
if( *disasmMedium )
AddResultString( disasmMedium );
if( *disasmShort )
AddResultString( disasmShort );
}
else if( data.busPhase == MCS4busPhaseX3 && data.prevInstrState == MCS4prevInstrNormal )
{ // show effective values on he bus

switch( data.instrVal & 0xf9 )
{
case 0x21:
case 0x29: // SRC

AnalyzerHelpers::GetNumberString( data.busValAtX2 * 16 + data.busVal, display_base, 8, number_str, sizeof( number_str ) );
AddResultString( "(adr ", number_str, ")" );
AddResultString( "(", number_str, ")" );
AddResultString( number_str ); // shorter string variant
break;

case 0xe0:
case 0xe1: // mem write
AnalyzerHelpers::GetNumberString( data.busValAtX2, display_base, 4, number_str, sizeof( number_str ) );
AddResultString( "(wr ", number_str, ")" );
AddResultString( "(", number_str, ")" );
AddResultString( number_str ); // shorter string variant
break;

case 0xe8:
case 0xe9:
AnalyzerHelpers::GetNumberString( data.busValAtX2, display_base, 4, number_str, sizeof( number_str ) );
AddResultString( "(rd ", number_str, ")" );
AddResultString( "(", number_str, ")" );
AddResultString( number_str ); // shorter string variant
break;
}
}
}
}

void MCS04AnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
{
std::ofstream file_stream( file, std::ios::out );
std::ofstream file_stream( file, std::ios::out );

file_stream.close();

file_stream.close();
}

void MCS04AnalyzerResults::GenerateFrameTabularText( U64 frame_index, DisplayBase display_base )
{
#ifdef SUPPORTS_PROTOCOL_SEARCH
Frame frame = GetFrame( frame_index );
ClearTabularText();
Frame frame = GetFrame( frame_index );
ClearTabularText();

char number_str[128];
AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );
AddTabularText( number_str );
char number_str[ 128 ];
AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );
AddTabularText( number_str );
#endif
}

void MCS04AnalyzerResults::GeneratePacketTabularText( U64 packet_id, DisplayBase display_base )
{
//not supported

// not supported
}

void MCS04AnalyzerResults::GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base )
{
//not supported
// not supported
}
70 changes: 35 additions & 35 deletions src/MCS04AnalyzerResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,52 @@
class MCS04Analyzer;
class MCS04AnalyzerSettings;

enum MCS4busPhase {
MCS4busPhaseInvalid,
MCS4busPhaseA1,
MCS4busPhaseA2,
MCS4busPhaseA3,
MCS4busPhaseM1,
MCS4busPhaseM2,
MCS4busPhaseX1,
MCS4busPhaseX2,
MCS4busPhaseX3,
enum MCS4busPhase
{
MCS4busPhaseInvalid,
MCS4busPhaseA1,
MCS4busPhaseA2,
MCS4busPhaseA3,
MCS4busPhaseM1,
MCS4busPhaseM2,
MCS4busPhaseX1,
MCS4busPhaseX2,
MCS4busPhaseX3,
};


union MCS4data {
U64 mData1;
struct {
U32 busVal : 4; //val on the bus
U32 busPhase : 4; //enum MCS4busPhase
U32 prevInstrState : 3; //enum MCS4prevInstrState
U32 prevInstrOPA : 4;
U32 romAddr : 12;
U32 instrVal : 8;
U32 busValAtX2 : 4; //only valid after x2... duh?
};
U64 mData1;
struct
{
U32 busVal : 4; // val on the bus
U32 busPhase : 4; // enum MCS4busPhase
U32 prevInstrState : 3; // enum MCS4prevInstrState
U32 prevInstrOPA : 4;
U32 romAddr : 12;
U32 instrVal : 8;
U32 busValAtX2 : 4; // only valid after x2... duh?
};
};



class MCS04AnalyzerResults : public AnalyzerResults
{
public:
MCS04AnalyzerResults( MCS04Analyzer* analyzer, MCS04AnalyzerSettings* settings );
virtual ~MCS04AnalyzerResults();

virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base );
virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id );
public:
MCS04AnalyzerResults( MCS04Analyzer* analyzer, MCS04AnalyzerSettings* settings );
virtual ~MCS04AnalyzerResults();

virtual void GenerateFrameTabularText(U64 frame_index, DisplayBase display_base );
virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base );
virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base );
virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base );
virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id );

protected: //functions
virtual void GenerateFrameTabularText( U64 frame_index, DisplayBase display_base );
virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base );
virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base );

protected: //vars
MCS04AnalyzerSettings* mSettings;
MCS04Analyzer* mAnalyzer;
protected: // functions
protected: // vars
MCS04AnalyzerSettings* mSettings;
MCS04Analyzer* mAnalyzer;
};

#endif //MCS04_ANALYZER_RESULTS
#endif // MCS04_ANALYZER_RESULTS
Loading

0 comments on commit 91426d1

Please sign in to comment.