mirror of
https://github.com/libretro/Play-.git
synced 2025-02-12 20:29:11 +00:00
Merge branch 'master' into dynasty_warriors2
This commit is contained in:
commit
8886cf41c7
@ -15,7 +15,7 @@ struct AOT_BLOCK_KEY
|
||||
|
||||
bool operator <(const AOT_BLOCK_KEY& k2) const
|
||||
{
|
||||
const AOT_BLOCK_KEY& k1 = (*this);
|
||||
const auto& k1 = (*this);
|
||||
if(k1.crc == k2.crc)
|
||||
{
|
||||
if(k1.begin == k2.begin)
|
||||
|
39
Source/androidui/NativeInterop.cpp
Normal file
39
Source/androidui/NativeInterop.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include <jni.h>
|
||||
#include <cassert>
|
||||
#include <android/log.h>
|
||||
#include "PathUtils.h"
|
||||
#include "../PS2VM.h"
|
||||
|
||||
#define LOG_NAME "Play!"
|
||||
|
||||
static CPS2VM* g_virtualMachine = nullptr;
|
||||
|
||||
void Log_Print(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
__android_log_vprint(ANDROID_LOG_INFO, LOG_NAME, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_virtualapplications_play_NativeInterop_setFilesDirPath(JNIEnv* env, jobject obj, jstring dirPathString)
|
||||
{
|
||||
auto dirPath = env->GetStringUTFChars(dirPathString, 0);
|
||||
Framework::PathUtils::SetFilesDirPath(dirPath);
|
||||
env->ReleaseStringUTFChars(dirPathString, dirPath);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_virtualapplications_play_NativeInterop_createVirtualMachine(JNIEnv* env, jobject obj)
|
||||
{
|
||||
g_virtualMachine = new CPS2VM();
|
||||
g_virtualMachine->Initialize();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_virtualapplications_play_NativeInterop_start(JNIEnv* env, jobject obj)
|
||||
{
|
||||
g_virtualMachine->Reset();
|
||||
g_virtualMachine->m_ee->m_os->BootFromFile("/storage/emulated/legacy/demo2b.elf");
|
||||
Log_Print("Before step.");
|
||||
g_virtualMachine->StepEe();
|
||||
Log_Print("Stepping.");
|
||||
}
|
@ -5,10 +5,10 @@
|
||||
android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="19" />
|
||||
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<application android:label="@string/app_name">
|
||||
<activity
|
||||
android:name="com.virtualapplications.play.MainActivity"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -1,20 +0,0 @@
|
||||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked in Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
||||
palleon.dir=C:/Projects/Palleon
|
||||
source.dir=${palleon.dir}/src/android/java
|
||||
asset.dir=../data/
|
4
build_android/debug_debug.sh
Normal file
4
build_android/debug_debug.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
adb install -r ./bin/Play-debug.apk
|
||||
$ANDROID_NDK_ROOT/ndk-gdb --nowait --start
|
@ -27,6 +27,7 @@ include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libPlay
|
||||
LOCAL_SRC_FILES := ../../Source/AppConfig.cpp \
|
||||
../../Source/androidui/NativeInterop.cpp \
|
||||
../../Source/BasicBlock.cpp \
|
||||
../../Source/COP_FPU.cpp \
|
||||
../../Source/COP_FPU_Reflection.cpp \
|
||||
@ -141,10 +142,10 @@ LOCAL_SRC_FILES := ../../Source/AppConfig.cpp \
|
||||
../../Source/VuExecutor.cpp \
|
||||
../../Source/VUShared.cpp \
|
||||
../../Source/VUShared_Reflection.cpp
|
||||
LOCAL_CFLAGS := -Wno-extern-c-compat -D_IOP_EMULATE_MODULES -D_DEBUG
|
||||
LOCAL_CFLAGS := -Wno-extern-c-compat -D_IOP_EMULATE_MODULES -D_DEBUG -DDISABLE_LOGGING
|
||||
LOCAL_C_INCLUDES := $(BOOST_PATH) $(FRAMEWORK_PATH)/include $(CODEGEN_PATH)/include $(LOCAL_PATH)/../../include
|
||||
LOCAL_CPP_FEATURES := exceptions rtti
|
||||
LOCAL_LDLIBS := -landroid -lz
|
||||
LOCAL_LDLIBS := -landroid -llog -lz
|
||||
LOCAL_STATIC_LIBRARIES := libCodeGen libFramework libboost
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
13
build_android/res/layout/main.xml
Normal file
13
build_android/res/layout/main.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<Button
|
||||
android:id="@+id/startTests"
|
||||
android:text="Start Tests"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
@ -0,0 +1,33 @@
|
||||
package com.virtualapplications.play;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.View.*;
|
||||
import android.widget.*;
|
||||
import java.io.*;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
@Override protected void onCreate(Bundle icicle)
|
||||
{
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
File filesDir = getFilesDir();
|
||||
NativeInterop.setFilesDirPath(filesDir.getAbsolutePath());
|
||||
|
||||
NativeInterop.createVirtualMachine();
|
||||
|
||||
((Button)findViewById(R.id.startTests)).setOnClickListener(
|
||||
new OnClickListener()
|
||||
{
|
||||
public void onClick(View view)
|
||||
{
|
||||
NativeInterop.start();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.virtualapplications.play;
|
||||
|
||||
public class NativeInterop
|
||||
{
|
||||
static
|
||||
{
|
||||
System.loadLibrary("Play");
|
||||
}
|
||||
|
||||
public static native void setFilesDirPath(String dirPath);
|
||||
public static native void createVirtualMachine();
|
||||
public static native void start();
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "PsfVm.h"
|
||||
#include "PsfLoader.h"
|
||||
#include "MemoryUtils.h"
|
||||
@ -9,8 +10,8 @@
|
||||
#include "Jitter_CodeGen_Arm.h"
|
||||
#include "MemStream.h"
|
||||
#include "Iop_PsfSubSystem.h"
|
||||
#include "psp/Psp_PsfSubSystem.h"
|
||||
#include "ThreadPool.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "Playlist.h"
|
||||
#include "make_unique.h"
|
||||
|
||||
@ -111,9 +112,9 @@ unsigned int CompileFunction(CPsfVm& virtualMachine, CMipsJitter* jitter, const
|
||||
|
||||
jitter->SetStream(&outputStream);
|
||||
jitter->Begin();
|
||||
|
||||
for(uint32 address = begin; address <= end; address += 4)
|
||||
{
|
||||
|
||||
for(uint32 address = begin; address <= end; address += 4)
|
||||
{
|
||||
context.m_pArch->CompileInstruction(address, jitter, &context);
|
||||
//Sanity check
|
||||
assert(jitter->IsStackEmpty());
|
||||
@ -128,7 +129,7 @@ unsigned int CompileFunction(CPsfVm& virtualMachine, CMipsJitter* jitter, const
|
||||
}
|
||||
}
|
||||
|
||||
AotBlockMap GetBlocksFromCache(const filesystem::path& blockCachePath)
|
||||
AotBlockMap GetBlocksFromCache(const filesystem::path& blockCachePath, const char* cacheFilter)
|
||||
{
|
||||
AotBlockMap result;
|
||||
|
||||
@ -137,6 +138,12 @@ AotBlockMap GetBlocksFromCache(const filesystem::path& blockCachePath)
|
||||
pathIterator != path_end; pathIterator++)
|
||||
{
|
||||
const auto& filePath = (*pathIterator);
|
||||
auto filePathExtension = filePath.path().extension();
|
||||
if(filePathExtension.string() != std::string(cacheFilter))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("Processing %s...\r\n", filePath.path().string().c_str());
|
||||
|
||||
auto blockCacheStream = Framework::CreateInputStdStream(filePath.path().native());
|
||||
@ -181,12 +188,62 @@ AotBlockMap GetBlocksFromCache(const filesystem::path& blockCachePath)
|
||||
return result;
|
||||
}
|
||||
|
||||
void Compile(const char* databasePathName, const char* cpuArchName, const char* imageFormatName, const char* outputPath)
|
||||
void CompileFunctions(CPsfVm& virtualMachine, const AotBlockMap& blocks, CMipsJitter* jitter, Jitter::CObjectFile& objectFile, FunctionTable& functionTable)
|
||||
{
|
||||
functionTable.reserve(functionTable.size() + blocks.size());
|
||||
|
||||
for(const auto& blockCachePair : blocks)
|
||||
{
|
||||
const auto& blockKey = blockCachePair.first;
|
||||
|
||||
auto functionName = "aotblock_" + std::to_string(blockKey.crc) + "_" + std::to_string(blockKey.begin) + "_" + std::to_string(blockKey.end);
|
||||
|
||||
try
|
||||
{
|
||||
unsigned int functionSymbolIndex = CompileFunction(virtualMachine, jitter, blockCachePair.second, objectFile, functionName, blockKey.begin, blockKey.end);
|
||||
|
||||
FUNCTION_TABLE_ITEM tableItem = { blockKey, functionSymbolIndex };
|
||||
functionTable.push_back(tableItem);
|
||||
}
|
||||
catch(const std::exception& exception)
|
||||
{
|
||||
//We failed to add function to the table, we assume that it's because it was
|
||||
//already added in a previous pass (in PSP pass after IOP pass has been completed)
|
||||
printf("Warning: Failed to add function '%s' in table: %s.\r\n", functionName.c_str(), exception.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CompileIopFunctions(const char* databasePathName, CMipsJitter* jitter, Jitter::CObjectFile& objectFile, FunctionTable& functionTable)
|
||||
{
|
||||
filesystem::path databasePath(databasePathName);
|
||||
auto blocks = GetBlocksFromCache(databasePath, ".blockcache_iop");
|
||||
|
||||
printf("Got %d IOP blocks to compile.\r\n", blocks.size());
|
||||
|
||||
CPsfVm virtualMachine;
|
||||
auto subSystem = std::make_shared<Iop::CPsfSubSystem>(false);
|
||||
virtualMachine.SetSubSystem(subSystem);
|
||||
|
||||
CompileFunctions(virtualMachine, blocks, jitter, objectFile, functionTable);
|
||||
}
|
||||
|
||||
void CompilePspFunctions(const char* databasePathName, CMipsJitter* jitter, Jitter::CObjectFile& objectFile, FunctionTable& functionTable)
|
||||
{
|
||||
filesystem::path databasePath(databasePathName);
|
||||
auto blocks = GetBlocksFromCache(databasePath, ".blockcache_psp");
|
||||
|
||||
printf("Got %d PSP blocks to compile.\r\n", blocks.size());
|
||||
|
||||
CPsfVm virtualMachine;
|
||||
auto subSystem = std::make_shared<Psp::CPsfSubSystem>();
|
||||
virtualMachine.SetSubSystem(subSystem);
|
||||
|
||||
CompileFunctions(virtualMachine, blocks, jitter, objectFile, functionTable);
|
||||
}
|
||||
|
||||
void Compile(const char* databasePathName, const char* cpuArchName, const char* imageFormatName, const char* outputPath)
|
||||
{
|
||||
Jitter::CCodeGen* codeGen = nullptr;
|
||||
Jitter::CObjectFile::CPU_ARCH cpuArch = Jitter::CObjectFile::CPU_ARCH_X86;
|
||||
if(!strcmp(cpuArchName, "x86"))
|
||||
@ -230,9 +287,6 @@ void Compile(const char* databasePathName, const char* cpuArchName, const char*
|
||||
objectFile->AddExternalSymbol("_SWL_Proxy", &SWL_Proxy);
|
||||
objectFile->AddExternalSymbol("_SWR_Proxy", &SWR_Proxy);
|
||||
|
||||
filesystem::path databasePath(databasePathName);
|
||||
auto blocks = GetBlocksFromCache(databasePath);
|
||||
|
||||
//Initialize Jitter Service
|
||||
auto jitter = new CMipsJitter(codeGen);
|
||||
for(unsigned int i = 0; i < 4; i++)
|
||||
@ -243,22 +297,10 @@ void Compile(const char* databasePathName, const char* cpuArchName, const char*
|
||||
);
|
||||
}
|
||||
|
||||
printf("Got %d blocks to compile.\r\n", blocks.size());
|
||||
|
||||
FunctionTable functionTable;
|
||||
functionTable.reserve(blocks.size());
|
||||
|
||||
for(const auto& blockCachePair : blocks)
|
||||
{
|
||||
const auto& blockKey = blockCachePair.first;
|
||||
|
||||
auto functionName = "aotblock_" + std::to_string(blockKey.crc) + "_" + std::to_string(blockKey.begin) + "_" + std::to_string(blockKey.end);
|
||||
|
||||
unsigned int functionSymbolIndex = CompileFunction(virtualMachine, jitter, blockCachePair.second, *objectFile, functionName, blockKey.begin, blockKey.end);
|
||||
|
||||
FUNCTION_TABLE_ITEM tableItem = { blockKey, functionSymbolIndex };
|
||||
functionTable.push_back(tableItem);
|
||||
}
|
||||
CompileIopFunctions(databasePathName, jitter, *objectFile, functionTable);
|
||||
CompilePspFunctions(databasePathName, jitter, *objectFile, functionTable);
|
||||
|
||||
std::sort(functionTable.begin(), functionTable.end(),
|
||||
[] (const FUNCTION_TABLE_ITEM& item1, const FUNCTION_TABLE_ITEM& item2)
|
||||
@ -267,6 +309,7 @@ void Compile(const char* databasePathName, const char* cpuArchName, const char*
|
||||
}
|
||||
);
|
||||
|
||||
//Write out block table
|
||||
{
|
||||
Framework::CMemStream blockTableStream;
|
||||
Jitter::CObjectFile::INTERNAL_SYMBOL blockTableSymbol;
|
||||
@ -294,6 +337,7 @@ void Compile(const char* databasePathName, const char* cpuArchName, const char*
|
||||
objectFile->AddInternalSymbol(blockTableSymbol);
|
||||
}
|
||||
|
||||
//Write out block count
|
||||
{
|
||||
Jitter::CObjectFile::INTERNAL_SYMBOL blockCountSymbol;
|
||||
blockCountSymbol.name = "__aot_blockCount";
|
||||
|
@ -8,7 +8,7 @@
|
||||
<Target Name="Build">
|
||||
<MakeDir Directories="./blocks/" />
|
||||
<Exec
|
||||
Command=""$(PsfAotPath)" gather "%(PsfFile.Identity)" "./blocks/%(PsfFile.FileName).blockcache""
|
||||
Command=""$(PsfAotPath)" gather "%(PsfFile.Identity)" "./blocks/%(PsfFile.FileName).blockcache_iop""
|
||||
ContinueOnError="ErrorAndContinue"
|
||||
/>
|
||||
</Target>
|
||||
|
Loading…
x
Reference in New Issue
Block a user