map edit shows border around map
This commit is contained in:
parent
42f8174a51
commit
8f78bbdca1
|
@ -1,3 +1,6 @@
|
||||||
|
# 0.3.0
|
||||||
|
- added size to backgrounds
|
||||||
|
|
||||||
# 0.2.1 - 2023-07-27
|
# 0.2.1 - 2023-07-27
|
||||||
- fixed missing dependency in scaffolding
|
- fixed missing dependency in scaffolding
|
||||||
|
|
||||||
|
@ -8,4 +11,4 @@
|
||||||
- added gsa scaffolding tool
|
- added gsa scaffolding tool
|
||||||
|
|
||||||
# 0.1.0 - 2023-07-21
|
# 0.1.0 - 2023-07-21
|
||||||
initial release
|
- initial release
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
@ -19,6 +19,26 @@ use winit::{
|
||||||
const SPR_CURSOR: usize = 0x01;
|
const SPR_CURSOR: usize = 0x01;
|
||||||
const TILE_CURSOR: u16 = 0x7308;
|
const TILE_CURSOR: u16 = 0x7308;
|
||||||
const TILE_MARKER: u16 = 0x7309;
|
const TILE_MARKER: u16 = 0x7309;
|
||||||
|
const TILE_BG: u16 = 0x730a;
|
||||||
|
|
||||||
|
struct Surface<'a> {
|
||||||
|
pub data: &'a mut [u8],
|
||||||
|
pub size: IVec2,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Surface<'a> {
|
||||||
|
fn draw_vline(&mut self, pos: IVec2, len: i32, color: u8) {
|
||||||
|
for i in 0..len {
|
||||||
|
self.data[(pos.x + (pos.y + i) * self.size.x) as usize] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_hline(&mut self, pos: IVec2, len: i32, color: u8) {
|
||||||
|
for i in 0..len {
|
||||||
|
self.data[(pos.x + i + pos.y * self.size.x) as usize] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn run_mapedit() {
|
pub(crate) fn run_mapedit() {
|
||||||
println!("running map edit");
|
println!("running map edit");
|
||||||
|
@ -54,6 +74,9 @@ pub(crate) fn run_mapedit() {
|
||||||
};
|
};
|
||||||
gsa2.reset_bgs();
|
gsa2.reset_bgs();
|
||||||
gsa2.reset_sprites();
|
gsa2.reset_sprites();
|
||||||
|
for i in 0..2 {
|
||||||
|
gsa2.bgs[i].scroll = IVec2 { x: -16, y: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
for y in 0..TILESET_SIZE {
|
for y in 0..TILESET_SIZE {
|
||||||
for x in 0..TILESET_SIZE {
|
for x in 0..TILESET_SIZE {
|
||||||
|
@ -63,6 +86,7 @@ pub(crate) fn run_mapedit() {
|
||||||
gsa2.bgs[0].active = false;
|
gsa2.bgs[0].active = false;
|
||||||
gsa2.bgs[1].active = false;
|
gsa2.bgs[1].active = false;
|
||||||
gsa2.bgs[2].active = true;
|
gsa2.bgs[2].active = true;
|
||||||
|
gsa2.bgs[2].size = IVec2 { x: 120, y: 68 }; //enough to cover 4k monitors? <_<
|
||||||
|
|
||||||
for y in 0..BACKGROUND_MAX_SIZE {
|
for y in 0..BACKGROUND_MAX_SIZE {
|
||||||
gsa2.bgs[2].tiles[0][y] = 0x7408;
|
gsa2.bgs[2].tiles[0][y] = 0x7408;
|
||||||
|
@ -238,24 +262,43 @@ pub(crate) fn run_mapedit() {
|
||||||
let mut screen_buffer =
|
let mut screen_buffer =
|
||||||
vec![TRANSPARENT; size.width as usize * size.height as usize / 4];
|
vec![TRANSPARENT; size.width as usize * size.height as usize / 4];
|
||||||
let mut window_buffer = surface.buffer_mut().unwrap();
|
let mut window_buffer = surface.buffer_mut().unwrap();
|
||||||
render_to_screen(
|
let screen_size = IVec2 {
|
||||||
&mut screen_buffer,
|
x: size.width as i32 / 2,
|
||||||
&gsa,
|
y: size.height as i32 / 2,
|
||||||
&tileset,
|
};
|
||||||
IVec2 {
|
render_to_screen(&mut screen_buffer, &gsa, &tileset, screen_size);
|
||||||
x: size.width as i32 / 2,
|
render_to_screen(&mut screen_buffer, &gsa2, &tileset, screen_size);
|
||||||
y: size.height as i32 / 2,
|
let mut screen = Surface {
|
||||||
},
|
data: &mut screen_buffer,
|
||||||
);
|
size: screen_size,
|
||||||
render_to_screen(
|
};
|
||||||
&mut screen_buffer,
|
if gsa.bgs[0].active {
|
||||||
&gsa2,
|
let xs = -gsa.bgs[0].scroll.x - 1;
|
||||||
&tileset,
|
let ys = -gsa.bgs[0].scroll.y - 1;
|
||||||
IVec2 {
|
let xe = xs + gsa.bgs[0].size.x * TILE_SIZE as i32 + 1;
|
||||||
x: size.width as i32 / 2,
|
let ye = ys + gsa.bgs[0].size.y * TILE_SIZE as i32 + 1;
|
||||||
y: size.height as i32 / 2,
|
if xs >= 16 && xs < screen_size.x {
|
||||||
},
|
let starty = (ys + 1).max(0);
|
||||||
);
|
let len = ye.min(screen_size.y) - starty;
|
||||||
|
screen.draw_vline(IVec2 { x: xs, y: starty }, len, 0xfc);
|
||||||
|
}
|
||||||
|
if xe >= 16 && xe < screen_size.x {
|
||||||
|
let starty = (ys + 1).max(0);
|
||||||
|
let len = ye.min(screen_size.y) - starty;
|
||||||
|
screen.draw_vline(IVec2 { x: xe, y: starty }, len, 0xfc);
|
||||||
|
}
|
||||||
|
if ys >= 0 && ys < screen_size.y {
|
||||||
|
let startx = (xs + 1).max(16);
|
||||||
|
let len = xe.min(screen_size.x) - startx;
|
||||||
|
screen.draw_hline(IVec2 { x: startx, y: ys }, len, 0xfc);
|
||||||
|
}
|
||||||
|
if ye >= 0 && ye < screen_size.y {
|
||||||
|
let startx = (xs + 1).max(16);
|
||||||
|
let len = xe.min(screen_size.x) - startx;
|
||||||
|
screen.draw_hline(IVec2 { x: startx, y: ye }, len, 0xfc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render_to_window(
|
render_to_window(
|
||||||
&mut window_buffer,
|
&mut window_buffer,
|
||||||
&mut screen_buffer,
|
&mut screen_buffer,
|
||||||
|
|
Loading…
Reference in New Issue