1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::*;

/// "Mosaic Effect"
///
/// Sets the global intensity of the mosaic effect (for things that enabled it
/// at all).
#[cfg(feature = "unsafe_addresses")]
pub const MOSAIC: WriteOnlyVolAddr<MosaicControlValue> =
  unsafe { WriteOnlyVolAddr::new(0x0400_004C) };

/// Controls the intensity of the "mosaic" special effect.
///
/// You can set the effect intensity for all backgrounds and also for objects,
/// but then each background and object can also apply the effect (or not)
/// according to its own controls (see [`BackgroundControlValue`]).
///
/// The visual effect of the mosaic is that pixels in the source data will be
/// "duplicated" in the destination. When the mosaic is applied each "real"
/// pixel will be copied over X additional pixels to the left, or Y additional
/// pixels below, instead of what would normally be drawn there. When X or Y is
/// 0 then it's the same as having no effect applied at all in that direction.
///
/// The mosaic effect also interacts with offsets, so if you don't want the
/// duplication to start from the very upper left you can offset the background
/// or object up or to the left so that the effect starts in the "middle" of a
/// mosaic region.
#[repr(transparent)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct MosaicControlValue(u16);

#[rustfmt::skip]
#[allow(missing_docs)]
impl MosaicControlValue {
  pub_const_fn_new_zero!();
  unsigned_bits_u16!(0..=3, bg_horizontal, with_bg_horizontal, set_bg_horizontal);
  unsigned_bits_u16!(4..=7, bg_vertical, with_bg_vertical, set_bg_vertical);
  unsigned_bits_u16!(8..=11, obj_horizontal, with_obj_horizontal, set_obj_horizontal);
  unsigned_bits_u16!(12..=15, obj_vertical, with_obj_vertical, set_obj_vertical);
}