Skip to content

Commit

Permalink
Use vector directly on jni_driver.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBRDeveloper committed Dec 21, 2023
1 parent c0960dc commit 8b93ef7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/jni_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ void Pandroid::onSmdhLoaded(const std::vector<u8> &smdh){

jbyteArray result = env->NewByteArray(size);

jbyte buffer[size];

for(int i = 0; i < size; i++){
buffer[i] = (jbyte) smdh[i];
}
env->SetByteArrayRegion(result, 0, size, buffer);
env->SetByteArrayRegion(result, 0, size, (jbyte*)smdh.data());


auto clazz = env->FindClass(alberClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public class AlberDriver {
public static native void TouchScreenDown(int x, int y);

public static void OnSmdhLoaded(byte[] buffer) {
Log.i(Constants.LOG_TAG, "Loaded rom smdh");
SMDH smdh = new SMDH(buffer);
Log.i(Constants.LOG_TAG, "Loaded rom SDMH");
Log.i(Constants.LOG_TAG, String.format("Are you playing '%s' published by '%s'", smdh.getTitle(), smdh.getPublisher()));
GameMetadata game = GameUtils.getCurrentGame();
GameUtils.removeGame(game);
GameUtils.addGame(GameMetadata.applySMDH(game, smdh));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import androidx.annotation.Nullable;

import com.panda3ds.pandroid.AlberDriver;
import com.panda3ds.pandroid.R;
import com.panda3ds.pandroid.app.game.AlberInputListener;
import com.panda3ds.pandroid.input.InputHandler;
Expand Down Expand Up @@ -80,4 +81,12 @@ public boolean dispatchGenericMotionEvent(MotionEvent ev) {

return super.dispatchGenericMotionEvent(ev);
}

@Override
protected void onDestroy() {
if(AlberDriver.HasRomLoaded()){
AlberDriver.Finalize();
}
super.onDestroy();
}
}

0 comments on commit 8b93ef7

Please sign in to comment.