mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Generate a bytestring for the image converter rather than the array
This commit is contained in:
parent
3c09a86f88
commit
d4a12277eb
|
@ -1,6 +1,6 @@
|
||||||
use crate::image_loader::Image;
|
|
||||||
use crate::palette16::Palette16OptimisationResults;
|
use crate::palette16::Palette16OptimisationResults;
|
||||||
use crate::TileSize;
|
use crate::TileSize;
|
||||||
|
use crate::{image_loader::Image, ByteString};
|
||||||
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
@ -49,7 +49,7 @@ pub(crate) fn generate_code(
|
||||||
for inner_y in 0..tile_size / 8 {
|
for inner_y in 0..tile_size / 8 {
|
||||||
for inner_x in 0..tile_size / 8 {
|
for inner_x in 0..tile_size / 8 {
|
||||||
for j in inner_y * 8..inner_y * 8 + 8 {
|
for j in inner_y * 8..inner_y * 8 + 8 {
|
||||||
for i in (inner_x * 8..inner_x * 8 + 8).rev() {
|
for i in inner_x * 8..inner_x * 8 + 8 {
|
||||||
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
||||||
tile_data.push(palette.colour_index(colour));
|
tile_data.push(palette.colour_index(colour));
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,12 @@ pub(crate) fn generate_code(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tile_data = tile_data.chunks(8)
|
let tile_data: Vec<_> = tile_data
|
||||||
.map(|chunk| chunk.iter().fold(0u32, |acc, &x| (acc << 4) | (x as u32)));
|
.chunks(2)
|
||||||
|
.map(|chunk| (chunk[1] << 4) | chunk[0])
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let data = ByteString(&tile_data);
|
||||||
|
|
||||||
let assignments = results.assignments.iter().map(|&x| x as u8);
|
let assignments = results.assignments.iter().map(|&x| x as u8);
|
||||||
|
|
||||||
|
@ -73,9 +77,7 @@ pub(crate) fn generate_code(
|
||||||
#(#palette_data),*
|
#(#palette_data),*
|
||||||
];
|
];
|
||||||
|
|
||||||
const TILE_DATA: &[u32] = &[
|
const TILE_DATA: &[u8] = #data;
|
||||||
#(#tile_data),*
|
|
||||||
];
|
|
||||||
|
|
||||||
const PALETTE_ASSIGNMENT: &[u8] = &[
|
const PALETTE_ASSIGNMENT: &[u8] = &[
|
||||||
#(#assignments),*
|
#(#assignments),*
|
||||||
|
|
Loading…
Reference in a new issue