mirror of
https://github.com/Inori/GPCS4.git
synced 2024-05-20 13:07:58 -04:00
4d6908b4ac
support copy as uint for hex bytes
67 lines
1.5 KiB
Plaintext
67 lines
1.5 KiB
Plaintext
//------------------------------------------------
|
|
//--- 010 Editor v3.0 Script File
|
|
//
|
|
// Author: Asuka
|
|
// Revision: 1.0
|
|
// Purpose: Defines a template for
|
|
// parsing AMD PM4 packet queue.
|
|
// Changes:
|
|
// 1.0:
|
|
// - Initial version.
|
|
//------------------------------------------------
|
|
|
|
int i, origfile, newfile, start, size, col, writeHeader;
|
|
|
|
// Determine range to copy
|
|
if( GetSelSize() == 0 )
|
|
{
|
|
start = 0;
|
|
size = FileSize();
|
|
}
|
|
else
|
|
{
|
|
start = GetSelStart();
|
|
size = GetSelSize();
|
|
}
|
|
|
|
// Create a new file for writing data
|
|
origfile = GetFileNum();
|
|
newfile = FileNew();
|
|
FileSelect( origfile );
|
|
|
|
// Convert each int to hex
|
|
int sizeInDwords = size/sizeof(unsigned int);
|
|
FPrintf( newfile, "unsigned int table[%d] =\r\n{\r\n ", sizeInDwords);
|
|
|
|
col = 0;
|
|
writeHeader = false;
|
|
for( i = 0; i < sizeInDwords; i++ )
|
|
{
|
|
// Write header at the beginning of the file
|
|
if( writeHeader )
|
|
{
|
|
FPrintf( newfile, " " );
|
|
writeHeader = false;
|
|
}
|
|
|
|
// Write int converted to hex
|
|
if( col > 0 )
|
|
FPrintf( newfile, ", " );
|
|
FPrintf( newfile, "%d", ReadUInt(start + i * sizeof(unsigned int)) );
|
|
|
|
// Write end of line every 8 bytes
|
|
if( ++col == 8 )
|
|
{
|
|
FPrintf( newfile, ", \r\n" );
|
|
writeHeader = true;
|
|
col = 0;
|
|
}
|
|
}
|
|
FPrintf( newfile, "\n};" );
|
|
// Copy to clipboard and close the file
|
|
FileSelect( newfile );
|
|
SetSelection( 0, FileSize() );
|
|
CutToClipboard();
|
|
FileClose();
|
|
FileSelect( origfile );
|