ba2eff82ac
Mainly convert mainloop and audio thread into native code for performance increase. (Calling into JNI every frame was costy) The code was cleaned up quite a bit, but I may have introduced new bugs in this process :< Former-commit-id: fdbc21b5ab39f3d2e36647fd1177dc9a84a16980 Former-commit-id: ac765dbee8c994e1b69cc694846511837c2685b9
35 lines
970 B
Rust
35 lines
970 B
Rust
use jni::objects::*;
|
|
use jni::sys::*;
|
|
use jni::JNIEnv;
|
|
|
|
use rustboyadvance_core::cartridge;
|
|
|
|
fn parse_rom_header(env: &JNIEnv, barr: jbyteArray) -> cartridge::header::CartridgeHeader {
|
|
let rom_data = env.convert_byte_array(barr).unwrap();
|
|
cartridge::header::parse(&rom_data).unwrap()
|
|
}
|
|
|
|
mod bindings {
|
|
use super::*;
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn Java_com_mrmichel_rustboyadvance_RomHelper_getGameCode(
|
|
env: JNIEnv,
|
|
_obj: JClass,
|
|
rom_data: jbyteArray,
|
|
) -> jstring {
|
|
let header = parse_rom_header(&env, rom_data);
|
|
env.new_string(header.game_code).unwrap().into_inner()
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn Java_com_mrmichel_rustboyadvance_RomHelper_getGameTitle(
|
|
env: JNIEnv,
|
|
_obj: JClass,
|
|
rom_data: jbyteArray,
|
|
) -> jstring {
|
|
let header = parse_rom_header(&env, rom_data);
|
|
env.new_string(header.game_title).unwrap().into_inner()
|
|
}
|
|
}
|