mirror of
https://github.com/italicsjenga/agb.git
synced 2025-02-02 12:36:35 +11:00
Extract function
This commit is contained in:
parent
07318256e0
commit
d278d50528
1 changed files with 13 additions and 8 deletions
|
@ -1,22 +1,29 @@
|
|||
use std::{
|
||||
fs,
|
||||
error, fs,
|
||||
io::{BufWriter, Write},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn main() -> Result<(), Box<dyn error::Error>> {
|
||||
let mut output = BufWriter::new(fs::File::create("out.gba")?);
|
||||
|
||||
let path = PathBuf::from("tests/text_render");
|
||||
let file_data = fs::read(path)?;
|
||||
let file_data = file_data.as_slice();
|
||||
|
||||
let elf_file = elf::ElfBytes::<elf::endian::AnyEndian>::minimal_parse(file_data)?;
|
||||
write_gba_file(file_data.as_slice(), &mut output)?;
|
||||
|
||||
output.flush()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_gba_file<W: Write>(input: &[u8], output: &mut W) -> Result<(), Box<dyn error::Error>> {
|
||||
let elf_file = elf::ElfBytes::<elf::endian::AnyEndian>::minimal_parse(input)?;
|
||||
|
||||
let section_headers = elf_file
|
||||
.section_headers()
|
||||
.expect("Expected section headers");
|
||||
|
||||
let mut output = BufWriter::new(fs::File::create("out.gba")?);
|
||||
|
||||
let mut header = gbafix::GBAHeader::default();
|
||||
|
||||
const GBA_START_ADDRESS: u64 = 0x8000000;
|
||||
|
@ -64,7 +71,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
address += data.len() as u64;
|
||||
}
|
||||
|
||||
output.flush()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue