d218325b12
Former-commit-id: e60d535f0c9b73209109b1040f6780b10c6b1174
31 lines
859 B
Rust
31 lines
859 B
Rust
use jni::objects::*;
|
|
use jni::sys::*;
|
|
use jni::JNIEnv;
|
|
|
|
use rustboyadvance_core::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)
|
|
}
|
|
|
|
#[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()
|
|
}
|