Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggering CI, ignore #4

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/Android_Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Android Build

on:
push:
branches:
- master
pull_request:

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
x64:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Fetch submodules
run: git submodule update --init --recursive

- name: Setup Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-use-cache: true
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Tools, Glslang

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86_64 -DENABLE_VULKAN=0

- name: Build
run: |
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/x86_64/
cd src/pandroid
./gradlew assembleDebug
cd ../..

- name: Upload executable
uses: actions/upload-artifact@v2
with:
name: Android APK (x86-64)
path: './src/pandroid/app/build/outputs/apk/debug/app-debug.apk'

arm64:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Fetch submodules
run: git submodule update --init --recursive

- name: Setup Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-use-cache: true
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Tools, Glslang

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'

- name: Apply GLES patch
run: git apply patch.patch

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DENABLE_VULKAN=0 -DCMAKE_CXX_FLAGS="-march=armv8.1-a+crypto"

- name: Build
run: |
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/arm64-v8a/
cd src/pandroid
./gradlew assembleDebug
cd ../..

- name: Upload executable
uses: actions/upload-artifact@v2
with:
name: Android APK (arm64)
path: './src/pandroid/app/build/outputs/apk/debug/app-debug.apk'

6 changes: 4 additions & 2 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ struct EmulatorConfig {
// Default to 3% battery to make users suffer
int batteryPercentage = 3;

std::filesystem::path filePath;

EmulatorConfig(const std::filesystem::path& path);
void load(const std::filesystem::path& path);
void save(const std::filesystem::path& path);
void load();
void save();
};
3 changes: 3 additions & 0 deletions include/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,7 @@ class Emulator {
RendererType getRendererType() const { return config.rendererType; }
Renderer* getRenderer() { return gpu.getRenderer(); }
u64 getTicks() { return cpu.getTicks(); }

std::filesystem::path getConfigPath();
std::filesystem::path getAndroidAppPath();
};
7 changes: 7 additions & 0 deletions include/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ namespace Helpers {
return false;
}

static constexpr bool isAndroid() {
#ifdef __ANDROID__
return true;
#endif
return false;
}

static void debug_printf(const char* fmt, ...) {
if constexpr (buildingInDebugMode()) {
std::va_list args;
Expand Down
118 changes: 118 additions & 0 deletions patch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
diff --git a/src/host_shaders/opengl_display.frag b/src/host_shaders/opengl_display.frag
index 612671c8..1937f711 100644
--- a/src/host_shaders/opengl_display.frag
+++ b/src/host_shaders/opengl_display.frag
@@ -1,4 +1,5 @@
-#version 410 core
+#version 300 es
+precision mediump float;
in vec2 UV;
out vec4 FragColor;

diff --git a/src/host_shaders/opengl_display.vert b/src/host_shaders/opengl_display.vert
index 990e2f80..6917c23c 100644
--- a/src/host_shaders/opengl_display.vert
+++ b/src/host_shaders/opengl_display.vert
@@ -1,4 +1,4 @@
-#version 410 core
+#version 300 es
out vec2 UV;

void main() {
diff --git a/src/host_shaders/opengl_fragment_shader.frag b/src/host_shaders/opengl_fragment_shader.frag
index f6fa6c55..b0850438 100644
--- a/src/host_shaders/opengl_fragment_shader.frag
+++ b/src/host_shaders/opengl_fragment_shader.frag
@@ -1,4 +1,5 @@
-#version 410 core
+#version 300 es
+precision mediump float;

in vec3 v_tangent;
in vec3 v_normal;
@@ -27,7 +28,7 @@ uniform bool u_depthmapEnable;
uniform sampler2D u_tex0;
uniform sampler2D u_tex1;
uniform sampler2D u_tex2;
-uniform sampler1DArray u_tex_lighting_lut;
+// uniform sampler1DArray u_tex_lighting_lut;

uniform uint u_picaRegs[0x200 - 0x48];

@@ -145,9 +146,15 @@ vec4 tevCalculateCombiner(int tev_id) {
#define RR_LUT 6u

float lutLookup(uint lut, uint light, float value) {
- if (lut >= FR_LUT && lut <= RR_LUT) lut -= 1;
- if (lut == SP_LUT) lut = light + 8;
- return texture(u_tex_lighting_lut, vec2(value, lut)).r;
+ // if (lut >= FR_LUT && lut <= RR_LUT) lut -= 1;
+ // if (lut == SP_LUT) lut = light + 8;
+ // return texture(u_tex_lighting_lut, vec2(value, lut)).r;
+ return 0.0;
+}
+
+uint bitfieldExtract(uint val, int off, int size) {
+ uint mask = uint((1 << size) - 1);
+ return uint(val >> off) & mask;
}

vec3 regToColor(uint reg) {
diff --git a/src/host_shaders/opengl_vertex_shader.vert b/src/host_shaders/opengl_vertex_shader.vert
index a25d7a6d..5967ccd6 100644
--- a/src/host_shaders/opengl_vertex_shader.vert
+++ b/src/host_shaders/opengl_vertex_shader.vert
@@ -1,4 +1,4 @@
-#version 410 core
+#version 300 es

layout(location = 0) in vec4 a_coords;
layout(location = 1) in vec4 a_quaternion;
@@ -20,7 +20,7 @@ out vec2 v_texcoord2;
flat out vec4 v_textureEnvColor[6];
flat out vec4 v_textureEnvBufferColor;

-out float gl_ClipDistance[2];
+// out float gl_ClipDistance[2];

// TEV uniforms
uniform uint u_textureEnvColor[6];
@@ -93,6 +93,6 @@ void main() {
);

// There's also another, always-on clipping plane based on vertex z
- gl_ClipDistance[0] = -a_coords.z;
- gl_ClipDistance[1] = dot(clipData, a_coords);
+ // gl_ClipDistance[0] = -a_coords.z;
+ // gl_ClipDistance[1] = dot(clipData, a_coords);
}
diff --git a/third_party/opengl/opengl.hpp b/third_party/opengl/opengl.hpp
index f368f573..5ead7f63 100644
--- a/third_party/opengl/opengl.hpp
+++ b/third_party/opengl/opengl.hpp
@@ -520,21 +520,21 @@ namespace OpenGL {
static void enableBlend() { glEnable(GL_BLEND); }
static void disableBlend() { glDisable(GL_BLEND); }
static void enableLogicOp() { glEnable(GL_COLOR_LOGIC_OP); }
- static void disableLogicOp() { glDisable(GL_COLOR_LOGIC_OP); }
+ static void disableLogicOp() { /* glDisable(GL_COLOR_LOGIC_OP); */ }
static void enableDepth() { glEnable(GL_DEPTH_TEST); }
static void disableDepth() { glDisable(GL_DEPTH_TEST); }
static void enableStencil() { glEnable(GL_STENCIL_TEST); }
static void disableStencil() { glDisable(GL_STENCIL_TEST); }

- static void enableClipPlane(GLuint index) { glEnable(GL_CLIP_DISTANCE0 + index); }
- static void disableClipPlane(GLuint index) { glDisable(GL_CLIP_DISTANCE0 + index); }
+ static void enableClipPlane(GLuint index) { /* glEnable(GL_CLIP_DISTANCE0 + index); */ }
+ static void disableClipPlane(GLuint index) { /* glDisable(GL_CLIP_DISTANCE0 + index); */ }

static void setDepthFunc(DepthFunc func) { glDepthFunc(static_cast<GLenum>(func)); }
static void setColourMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) { glColorMask(r, g, b, a); }
static void setDepthMask(GLboolean mask) { glDepthMask(mask); }

// TODO: Add a proper enum for this
- static void setLogicOp(GLenum op) { glLogicOp(op); }
+ static void setLogicOp(GLenum op) { /* glLogicOp(op); */ }

enum Primitives {
Triangle = GL_TRIANGLES,
11 changes: 7 additions & 4 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
// We are legally allowed, as per the author's wish, to use the above code without any licensing restrictions
// However we still want to follow the license as closely as possible and offer the proper attributions.

EmulatorConfig::EmulatorConfig(const std::filesystem::path& path) { load(path); }
EmulatorConfig::EmulatorConfig(const std::filesystem::path& path) : filePath(path) { load(); }

void EmulatorConfig::load() {
const std::filesystem::path& path = filePath;

void EmulatorConfig::load(const std::filesystem::path& path) {
// If the configuration file does not exist, create it and return
std::error_code error;
if (!std::filesystem::exists(path, error)) {
save(path);
save();
return;
}

Expand Down Expand Up @@ -84,8 +86,9 @@ void EmulatorConfig::load(const std::filesystem::path& path) {
}
}

void EmulatorConfig::save(const std::filesystem::path& path) {
void EmulatorConfig::save() {
toml::basic_value<toml::preserve_comments> data;
const std::filesystem::path& path = filePath;

std::error_code error;
if (std::filesystem::exists(path, error)) {
Expand Down
5 changes: 4 additions & 1 deletion src/core/services/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ void FSService::getThisSaveDataSecureValue(u32 messagePointer) {

mem.write32(messagePointer, IPC::responseHeader(0x86F, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write8(messagePointer + 8, 0); // Secure value does not exist
mem.write8(messagePointer + 12, 1); // TODO: What is this?
mem.write64(messagePointer + 16, 0); // Secure value
}

void FSService::setThisSaveDataSecureValue(u32 messagePointer) {
Expand Down Expand Up @@ -760,4 +763,4 @@ void FSService::renameFile(u32 messagePointer) {
// Everything is OK, let's do the rename. Both archives should match so we don't need the dest anymore
const HorizonResult res = sourceArchive->archive->renameFile(sourcePath, destPath);
mem.write32(messagePointer + 4, static_cast<u32>(res));
}
}
27 changes: 20 additions & 7 deletions src/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
#endif

Emulator::Emulator()
: config(std::filesystem::current_path() / "config.toml"), kernel(cpu, memory, gpu, config), cpu(memory, kernel), gpu(memory, config),
: config(getConfigPath()), kernel(cpu, memory, gpu, config), cpu(memory, kernel), gpu(memory, config),
memory(cpu.getTicksRef(), config), cheats(memory, kernel.getServiceManager().getHID()), lua(memory), running(false), programRunning(false)
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
, httpServer(this)
Expand All @@ -33,7 +33,7 @@ Emulator::Emulator()
}

Emulator::~Emulator() {
config.save(std::filesystem::current_path() / "config.toml");
config.save();
lua.close();

#ifdef PANDA3DS_ENABLE_DISCORD_RPC
Expand Down Expand Up @@ -70,6 +70,23 @@ void Emulator::reset(ReloadOption reload) {
}
}

std::filesystem::path Emulator::getAndroidAppPath() {
// SDL_GetPrefPath fails to get the path due to no JNI environment
std::ifstream cmdline("/proc/self/cmdline");
std::string applicationName;
std::getline(cmdline, applicationName, '\0');

return std::filesystem::path("/data") / "data" / applicationName / "files";
}

std::filesystem::path Emulator::getConfigPath() {
if constexpr (Helpers::isAndroid()) {
return getAndroidAppPath() / "config.toml";
} else {
return std::filesystem::current_path() / "config.toml";
}
}

void Emulator::step() {}
void Emulator::render() {}

Expand Down Expand Up @@ -117,11 +134,7 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
std::filesystem::path appDataPath;

#ifdef __ANDROID__
// SDL_GetPrefPath fails to get the path due to no JNI environment
std::ifstream cmdline("/proc/self/cmdline");
std::string applicationName;
std::getline(cmdline, applicationName, '\0');
appDataPath = std::filesystem::path("/data") / "data" / applicationName / "files";
appDataPath = getAndroidAppPath();
#else
char* appData;
if (!config.usePortableBuild) {
Expand Down
30 changes: 29 additions & 1 deletion src/jni_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_RunFram
renderer->setFBO(fbo);
renderer->resetStateManager();
emulator->runFrame();

emulator->getServiceManager().getHID().updateInputs(emulator->getTicks());
}

extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Finalize(JNIEnv* env, jobject obj) {
Expand All @@ -43,4 +45,30 @@ extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_LoadRom
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s", pathStr);
romLoaded = emulator->loadROM(pathStr);
env->ReleaseStringUTFChars(path, pathStr);
}
}



extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenDown(JNIEnv* env, jobject obj, jint x, jint y) {
emulator->getServiceManager().getHID().setTouchScreenPress((u16)x, (u16)y);
}

extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_TouchScreenUp(JNIEnv* env, jobject obj) {
emulator->getServiceManager().getHID().releaseTouchScreen();
}


extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_KeyUp(JNIEnv* env, jobject obj, jint keyCode) {
emulator->getServiceManager().getHID().releaseKey((u32)keyCode);
}

extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_KeyDown(JNIEnv* env, jobject obj, jint keyCode) {
emulator->getServiceManager().getHID().pressKey((u32)keyCode);
}

extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_SetCirclepadAxis(JNIEnv* env, jobject obj, jint x, jint y) {
emulator->getServiceManager().getHID().setCirclepadX((s16)x);
emulator->getServiceManager().getHID().setCirclepadY((s16)y);
}


Loading
Loading