This repository has been archived on 2024-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
rustboyadvance-ng/bindings/rustboyadvance-jni/src/rom_helper.rs

31 lines
859 B
Rust
Raw Normal View History

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()
}