Skip to content

Commit 79bfb9b

Browse files
committed
Update library and add title screen
Fixes the stupid wrong resolution which caused a black bar at the bottom (unallocated memory).
1 parent e9e0339 commit 79bfb9b

File tree

4 files changed

+53
-9
lines changed

4 files changed

+53
-9
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "doomarkable"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2018"
55

66
# Using build script to generate the dither cache
@@ -18,7 +18,7 @@ once_cell = "1"
1818
opt-level = 2
1919

2020
[dependencies]
21-
doomgeneric = { git = "https://github.com/LinusCDE/doomgeneric-rs.git", tag = "0.3.0-beta.1" }
21+
doomgeneric = { git = "https://github.com/LinusCDE/doomgeneric-rs.git", tag = "0.3.0-beta.2" }
2222
libremarkable = "0.5.0"
2323
once_cell = "1"
2424
fxhash = "0.2"

build/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1010
println!("cargo:rerun-if-changed=build/");
1111

1212
//let start = std::time::Instant::now();
13-
let dither_cache = blue_noise_calculator::calc_full_cache(320, 240);
13+
let dither_cache = blue_noise_calculator::calc_full_cache(320, 200);
1414
//println!("cargo:warning=Calculation took {:?}", start.elapsed());
1515

1616
let ref f_path = PathBuf::from(env::var("OUT_DIR")?).join("dither_cache.bin.zst");

src/main.rs

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,64 @@ fn main() {
8787
0,
8888
true,
8989
);
90+
fb.clear();
9091

9192
// The dither_cache was calculated in build/main.rs and
9293
// this env is set to the file path containing this cache.
9394
let start = Instant::now();
9495
let dither_cache_compressed = include_bytes!(env!("OUT_DIR_DITHERCACHE_FILE"));
9596
let mut dither_cache_raw = Cursor::new(Vec::with_capacity(
96-
blue_noise_dither::CachedDither2XTo4X::calc_dither_cache_len(320, 240) * 2,
97+
blue_noise_dither::CachedDither2XTo4X::calc_dither_cache_len(
98+
game::DOOMGENERIC_RESX as u32 / 2,
99+
game::DOOMGENERIC_RESY as u32 / 2,
100+
) * 2,
97101
));
98102
zstd::stream::copy_decode(Cursor::new(dither_cache_compressed), &mut dither_cache_raw).unwrap();
99103
let dither_cache_raw = dither_cache_raw.into_inner();
100104
let mut ditherer = blue_noise_dither::CachedDither2XTo4X::new(dither_cache_raw);
101105
info!("Loaded dither cache in {:?}", start.elapsed());
102106

107+
// Title
108+
let title_text = concat!("DOOMarkable v", env!("CARGO_PKG_VERSION"));
109+
let subtitle_text = "https://github.com/LinusCDE/doomarkable";
110+
let title_size = 80;
111+
let subtitle_size = 30;
112+
let title_rect = fb.draw_text(
113+
Point2 { x: 0f32, y: 0f32 },
114+
title_text,
115+
title_size as f32,
116+
common::color::BLACK,
117+
true,
118+
);
119+
let subtitle_rect = fb.draw_text(
120+
Point2 { x: 0f32, y: 0f32 },
121+
subtitle_text,
122+
subtitle_size as f32,
123+
common::color::BLACK,
124+
true,
125+
);
126+
127+
fb.draw_text(
128+
Point2 {
129+
x: (common::DISPLAYWIDTH as u32 - title_rect.width) as f32 / 2.0,
130+
y: (62 - 20 + title_size) as f32,
131+
},
132+
title_text,
133+
title_size as f32,
134+
common::color::BLACK,
135+
false,
136+
);
137+
fb.draw_text(
138+
Point2 {
139+
x: (common::DISPLAYWIDTH as u32 - subtitle_rect.width) as f32 / 2.0,
140+
y: (62 - 20 + title_size + subtitle_size) as f32,
141+
},
142+
subtitle_text,
143+
subtitle_size as f32,
144+
common::color::BLACK,
145+
false,
146+
);
147+
103148
// Keys
104149
let key_boxes = [
105150
(
@@ -196,7 +241,6 @@ fn main() {
196241
key_labels.insert(keys::KEY_ENTER, (25.0, "Enter"));
197242
key_labels.insert(*keys::KEY_USE, (25.0, "Use"));
198243

199-
fb.clear();
200244
for (boxx, key) in &key_boxes {
201245
fb.draw_rect(
202246
Point2 {
@@ -252,7 +296,7 @@ fn main() {
252296
let pos = Point2 {
253297
x: (common::DISPLAYWIDTH as i32 - width as i32) / 2,
254298
//y: (common::DISPLAYHEIGHT as i32 - height as i32) / 2,
255-
y: 62,
299+
y: 62 + 140,
256300
};
257301

258302
loop {

0 commit comments

Comments
 (0)