Compare commits

..

No commits in common. "8f78bbdca1e930b728f32077dafbc0f40f8727de" and "eebeb478d2f73135653b49caa937bce4764e4009" have entirely different histories.

5 changed files with 23 additions and 76 deletions

View File

@ -1,6 +1,3 @@
# 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
@ -11,4 +8,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

View File

@ -7,8 +7,6 @@ pub struct Background {
pub tiles: Vec<Vec<u16>>, pub tiles: Vec<Vec<u16>>,
/// Camera scroll (negative draw offset) for rendering /// Camera scroll (negative draw offset) for rendering
pub scroll: IVec2, pub scroll: IVec2,
/// Size (used for rendering)
pub size: IVec2,
/// Are tiles indices half-tile indices? /// Are tiles indices half-tile indices?
pub half_tile: bool, pub half_tile: bool,
/// Is this background being displayed? /// Is this background being displayed?
@ -24,7 +22,6 @@ impl Default for Background {
scroll: IVec2::ZERO, scroll: IVec2::ZERO,
half_tile: false, half_tile: false,
active: true, active: true,
size: IVec2 { x: 19, y: 11 },
} }
} }
} }

View File

@ -41,14 +41,10 @@ fn render_map(target: &mut [u8], map: &Background, tileset: &[u8], screen_size:
} as i32; } as i32;
let mut startx = map.scroll.x / tilesize; let mut startx = map.scroll.x / tilesize;
let mut starty = map.scroll.y / tilesize; let mut starty = map.scroll.y / tilesize;
let endx = map let endx =
.size (BACKGROUND_MAX_SIZE as i32).min(startx + (screen_size.x / TILE_SIZE as i32 + 1) * tcmult);
.x let endy =
.min(startx + (screen_size.x / TILE_SIZE as i32 + 1) * tcmult); (BACKGROUND_MAX_SIZE as i32).min(starty + (screen_size.y / TILE_SIZE as i32 + 1) * tcmult);
let endy = map
.size
.y
.min(starty + (screen_size.y / TILE_SIZE as i32 + 1) * tcmult);
startx = 0.max(startx); startx = 0.max(startx);
starty = 0.max(starty); starty = 0.max(starty);
for x in startx..endx { for x in startx..endx {

View File

@ -19,26 +19,6 @@ 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");
@ -74,9 +54,6 @@ 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 {
@ -86,7 +63,6 @@ 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;
@ -262,43 +238,24 @@ 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();
let screen_size = IVec2 { render_to_screen(
&mut screen_buffer,
&gsa,
&tileset,
IVec2 {
x: size.width as i32 / 2, x: size.width as i32 / 2,
y: size.height as i32 / 2, y: size.height as i32 / 2,
}; },
render_to_screen(&mut screen_buffer, &gsa, &tileset, screen_size); );
render_to_screen(&mut screen_buffer, &gsa2, &tileset, screen_size); render_to_screen(
let mut screen = Surface { &mut screen_buffer,
data: &mut screen_buffer, &gsa2,
size: screen_size, &tileset,
}; IVec2 {
if gsa.bgs[0].active { x: size.width as i32 / 2,
let xs = -gsa.bgs[0].scroll.x - 1; y: size.height as i32 / 2,
let ys = -gsa.bgs[0].scroll.y - 1; },
let xe = xs + gsa.bgs[0].size.x * TILE_SIZE as i32 + 1; );
let ye = ys + gsa.bgs[0].size.y * TILE_SIZE as i32 + 1;
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,