Tools: Remove bin2cpp

Stragglers from wx...
This commit is contained in:
Stenzek
2022-12-24 19:11:11 +10:00
committed by refractionpcsx2
parent 8696812d23
commit b8596c6f2a
13 changed files with 0 additions and 980 deletions

View File

@@ -1,4 +0,0 @@
# make bin2cpp
add_subdirectory(bin2cpp)

View File

@@ -1,26 +0,0 @@
#!/bin/sh
# PCSX2 - PS2 Emulator for PCs
# Copyright (C) 2002-2011 PCSX2 Dev Team
#
# PCSX2 is free software: you can redistribute it and/or modify it under the terms
# of the GNU Lesser General Public License as published by the Free Software Found-
# ation, either version 3 of the License, or (at your option) any later version.
#
# PCSX2 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 for more details.
#
# You should have received a copy of the GNU General Public License along with PCSX2.
# If not, see <http://www.gnu.org/licenses/>.
# Probably self-explanatory: This batch file compiles a single souce image into a
# CPP header file for use by pcsx2.
#
# bin2cpp.sh SrcImage
#
# Parameters
# SrcImage - Complete filename with extension.
#
$1/tools/bin/bin2cpp $2

View File

@@ -1,6 +0,0 @@
# bin2cpp tool
add_executable(bin2cpp bin2cpp.cpp)
# set output directory
# set_target_properties(${bin2cppName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/tools/bin)

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)common\vsprops\BaseProjectConfig.props" />
<Import Project="$(SolutionDir)common\vsprops\WinSDK.props" />
<PropertyGroup Label="Globals">
<ProjectName>bin2cpp</ProjectName>
<ProjectGuid>{677B7D11-D5E1-40B3-88B1-9A4DF83D2213}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(ProjectDir)..\bin\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<TargetMachine Condition="'$(Platform)'=='Win32'">MachineX86</TargetMachine>
<TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="bin2cpp.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="bin2cpp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -1,222 +0,0 @@
//
// BIN2CPP - Some hack-up Job of some mess I found online.
//
// Original was uncredited public domain. This is uncredited public domain.
// Who am I? You'll have to guess. Walrus, Eggman, or the taxman? Maybe.
//
// (Officially: Provided to the PCSX2 Dev Team by a combined effort on the part of
// the PCSX2 Dev Team and the glorious expanse of the information superhighway).
//
// ------------------------------------------------------------------------
//
// Changes from uncredited online version:
// * Lots of code cleanups.
// * Upgraded from K&R syntax (!) to CPP syntax.
// * added wxWidgets class-based interface for instantiating images in neat fashion.
// The class and interface used to read images from the host app can be found in
// wxEmbeddedImage.cpp.
//
// Actually I changed every line of code pretty much, except one that I felt really
// embodied the personality and spirit of this utility. It's the line that makes it
// print the following message upon command line misuse:
//
// Bad arguments !!! You must give me all the parameters !!!!
//
// ... I love it. I really do.
//
// Warning: This program is full of stack overflow holes and other mess. Maybe we'll
// rewrite it in C# someday and fix all that stuff, but for now it serves its purpose
// and accomplishes its menial tasks with sufficent effectiveness.
//
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <sys/stat.h>
#include <string.h>
#if _MSC_VER
# pragma warning(disable:4996) // The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name.
#endif
typedef unsigned char u8;
typedef char s8;
using namespace std;
static const unsigned int BUF_LEN = 1;
static const unsigned int LINE = 16;
/* Tell u the file size in bytes */
long getfilesize( const char* filename )
{
struct stat result;
stat( filename, &result );
return result.st_size;
}
enum
{
ARG_SRCFILE = 1,
ARG_DESTFILE,
ARG_CLASSNAME,
};
int main(int argc, char* argv[])
{
FILE *source,*dest;
u8 buffer[BUF_LEN];
s8 Dummy[260];
s8 srcfile[260];
s8 classname[260];
if ( (argc <= ARG_SRCFILE) )
{
if ( ( argc == 2 ) && ( strcmp(argv[1],"/?")==0 ) )
{
puts(
" - <<< BIN2CPP V1.1 For Win32 >>> by the PCSX2 Team - \n\n"
"USAGE: Bin2CPP <SOURCE image> [TARGET file] [CLASS]\n"
" <SOURCE> = without extension!\n"
" [TARGET] = without extension '.h' it will be added by program.\n"
" (defaults to <SOURCE> if unspecified)\n"
" [CLASS] = name of the C++ class in the destination file name.\n"
" (defaults to res_<TARGET> if unspecified)\n"
);
return 0L;
}
else
{
puts( "Bad arguments !!! You must give me all the parameters !!!!\n"
"Type 'BIN2CPP /?' to read the help.\n"
);
return 0L;
}
}
// ----------------------------------------------------------------------------
// Determine Source Name, and Open Source for Reading
// ----------------------------------------------------------------------------
strcpy(srcfile,argv[ARG_SRCFILE]);
const size_t srcfn_len = strlen( srcfile );
if( srcfn_len < 4 || srcfile[srcfn_len-4] != '.' )
{
printf( "ERROR : Malformed source filename. I'm a crap utility and I demand 3-letter extensions only!\n" );
return 18;
}
if( (source=fopen( srcfile, "rb" )) == NULL )
{
printf( "ERROR : I can't find source file %s\n", srcfile );
return 20;
}
const int filesize( getfilesize( srcfile ) );
char wxImgTypeUpper[24];
strcpy( wxImgTypeUpper, &srcfile[srcfn_len-3] );
int i = -1;
while(++i, wxImgTypeUpper[i] != 0)
wxImgTypeUpper[i] = toupper(wxImgTypeUpper[i]);
//strcpy( wxImgTypeLower, argv[ARG_IMGEXT] );
//char wxImgTypeLower[24];
if( strcmp( wxImgTypeUpper, "JPG" ) == 0 )
strcpy( wxImgTypeUpper, "JPEG" ); // because wxWidgets defines it as JPEG >_<
argv[ARG_SRCFILE][srcfn_len-4] = 0;
// ----------------------------------------------------------------------------
// Determine Target Name, and Open Target File for Writing
// ----------------------------------------------------------------------------
strcpy( Dummy, argv[(argc <= ARG_DESTFILE) ? ARG_SRCFILE : ARG_DESTFILE] );
strcat( Dummy,".h" );
if( (dest=fopen( Dummy, "wb+" )) == NULL )
{
printf( "ERROR : I can't open destination file %s\n", Dummy );
return 1;
}
// ----------------------------------------------------------------------------
printf( "Bin2CPP Output > %s\n", Dummy );
const char* fnameonly = NULL;
if( argc <= ARG_CLASSNAME )
{
fnameonly = argv[(argc <= ARG_DESTFILE) ? ARG_SRCFILE : ARG_DESTFILE];
strcpy( classname, "res_" );
}
else
{
fnameonly = argv[ARG_CLASSNAME];
classname[0] = 0;
}
{
int len = static_cast<int>(strlen(fnameonly));
const char* fnlast = &fnameonly[len];
while( --fnlast, --len, (len >= 0 && (*fnlast != '/')) );
fnameonly = fnlast+1;
}
strcpy( classname, "res_" );
strcat( classname, fnameonly );
/* It writes the header information */
fprintf( dest,
"#pragma once\n\n"
"#include \"common/Pcsx2Types.h\"\n"
"#include <wx/gdicmn.h>\n\n"
"class %s\n{\n"
"public:\n"
"\tstatic const uint Length = %d;\n"
"\tstatic const u8 Data[Length];\n"
"\tstatic wxBitmapType GetFormat() { return wxBITMAP_TYPE_%s; }\n};\n\n"
"const u8 %s::Data[Length] =\n{\n",
classname, filesize, wxImgTypeUpper, classname
);
if( ferror( dest ) )
{
printf( "ERROR writing on target file: %s\n", Dummy );
return 20L;
}
/* It writes the binary data information! */
do
{
fprintf(dest,"\t");
for ( unsigned int c=0; c <= LINE; ++c )
{
if( fread( buffer, 1, 1, source ) == 0 ) break;
if( c != 0 )
fprintf( dest, "," );
fprintf( dest,"0x%02x", *buffer );
}
if( !feof( source ) )
fprintf( dest, "," );
fprintf(dest,"\n");
}
while( ! feof( source ) );
fprintf(dest,"};\n");
return 0;
}