Struct spectrusty::chip::scld::frame_cache::SourceMode
source · pub struct SourceMode { /* private fields */ }
Expand description
Flags determining the screen data source for INK/PAPER masks and attributes.
source
attr sec. mode ink_mask attr
0 0 screen 0 screen 0 screen 0 attr. (8 lines)
0 1 screen 1 screen 1 screen 1 attr. (8 lines)
1 0 combined screen 0 screen 1
1 1 combined screen 1 screen 1
Implementations§
source§impl SourceMode
impl SourceMode
sourcepub const SECOND_SCREEN: Self = _
pub const SECOND_SCREEN: Self = _
Determines the source of INK/PAPER masks.
sourcepub const ATTR_HI_COLOR: Self = _
pub const ATTR_HI_COLOR: Self = _
Determines the source of attributes together with SourceMode::SECOND_SCREEN.
pub const SOURCE_MASK: Self = _
sourcepub const SHADOW_BANK: Self = _
pub const SHADOW_BANK: Self = _
Determines the screen bank the data is read from.
sourcepub const fn bits(&self) -> u8
pub const fn bits(&self) -> u8
Returns the raw value of the flags currently stored.
Examples found in repository?
More examples
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
fn set_ctrl_flags_value(&mut self, flags: ScldCtrlFlags, ts: VideoTs) {
let diff_flags = self.cur_ctrl_flags ^ flags;
// mmu
if self.mem_paged != 0 && diff_flags.is_map_ex_rom() {
let map_ex_rom = flags.is_map_ex_rom();
for page in 0..8u8 {
let mask = 1 << page;
if self.mem_paged & mask != 0 { // DOCK/EX-ROM
if map_ex_rom { // EX-ROM
self.ula.memory.map_rom_bank(8 + (page as usize) % (M::ROM_BANKS_MAX - 9), page)
}
else { // DOCK
self.ula.memory.map_rom_bank(page as usize, page)
}.unwrap();
}
}
}
// source mode
if diff_flags.intersects(ScldCtrlFlags::SCREEN_SOURCE_MASK) {
let source_mode = SourceMode::from_scld_flags(flags);
self.source_changes.push((ts, source_mode.bits()).into());
}
// render mode
if flags.is_screen_hi_res() {
if diff_flags.intersects(ScldCtrlFlags::SCREEN_HI_RES|ScldCtrlFlags::HIRES_COLOR_MASK) {
self.push_mode_change(ts,
RenderMode::with_color(
RenderMode::HI_RESOLUTION, flags.hires_color_index()));
}
}
else if diff_flags.is_screen_hi_res() {
self.push_mode_change(ts,
RenderMode::with_color(
RenderMode::empty(), self.ula.last_border.into()));
}
self.cur_ctrl_flags = flags;
}
sourcepub const fn from_bits(bits: u8) -> Option<Self>
pub const fn from_bits(bits: u8) -> Option<Self>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
sourcepub const fn from_bits_truncate(bits: u8) -> Self
pub const fn from_bits_truncate(bits: u8) -> Self
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
Examples found in repository?
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
pub fn from_scld_flags(flags: ScldCtrlFlags) -> SourceMode {
SourceMode::from_bits_truncate(
(flags & ScldCtrlFlags::SCREEN_SOURCE_MASK).bits()
)
}
#[inline]
pub fn from_plus_reg_flags(flags: UlaPlusRegFlags) -> SourceMode {
/*
ula + source mode
0 0 0 -> 0 0 0 screen 0
0 0 1 -> 0 0 1 screen 1
0 1 0 -> 0 1 0 hi-color
0 1 1 -> 1 1 0 * hi-color (shadow)
1 0 0 -> 1 0 0 screen 0 (shadow)
1 0 1 -> 1 0 1 screen 1 (shadow)
1 1 0 -> 0 1 0 * hi-res
1 1 1 -> 1 1 0 * hi-res (shadow)
*/
match (flags & UlaPlusRegFlags::SCREEN_MODE_MASK).bits() {
0b110 => SourceMode::ATTR_HI_COLOR, // 0b010
0b011|
0b111 => SourceMode::SHADOW_BANK|SourceMode::ATTR_HI_COLOR, // 0b110
bits => SourceMode::from_bits_truncate(bits)
}
}
#[inline]
pub fn is_second_screen(self) -> bool {
self.intersects(SourceMode::SECOND_SCREEN)
}
#[inline]
pub fn is_hi_color(self) -> bool {
self.intersects(SourceMode::ATTR_HI_COLOR)
}
#[inline]
pub fn is_shadow_bank(self) -> bool {
self.intersects(SourceMode::SHADOW_BANK)
}
}
impl From<SourceMode> for u8 {
#[inline]
fn from(mode: SourceMode) -> u8 {
mode.bits()
}
}
impl From<VideoTsData2> for SourceMode {
#[inline]
fn from(vtsm: VideoTsData2) -> Self {
SourceMode::from_bits_truncate(vtsm.into_data())
}
}
impl std::error::Error for TryFromU8SourceModeError {}
impl fmt::Display for TryFromU8SourceModeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "converted integer (0x{:x}) contains extraneous bits for `SourceMode`", self.0)
}
}
impl TryFrom<u8> for SourceMode {
type Error = TryFromU8SourceModeError;
fn try_from(mode: u8) -> Result<Self, Self::Error> {
SourceMode::from_bits(mode).ok_or(TryFromU8SourceModeError(mode))
}
}
impl<'a, V> ScldFrameRef<'a, V> {
pub fn new(
screen0: &'a ScreenArray,
frame_cache0: &'a UlaFrameCache<V>,
screen1: &'a ScreenArray,
frame_cache1: &'a UlaFrameCache<V>
) -> Self
{
ScldFrameRef { screen0, screen1, frame_cache0, frame_cache1 }
}
}
impl<'a, V, I> ScldFrameProducer<'a, V, I>
where V: VideoFrame,
I: Iterator<Item=VideoTsData2>
{
pub fn new(
source: SourceMode,
screen0: &'a ScreenArray,
frame_cache0: &'a UlaFrameCache<V>,
screen1: &'a ScreenArray,
frame_cache1: &'a UlaFrameCache<V>,
mut source_changes: I
) -> Self
{
let line = 0;
let line_iter = EMPTY_LINE_ITER;
let (next_change_at, next_source) = source_changes.next()
.map(|tsm| vtm_next::<V>(tsm, line as Ts))
.unwrap_or_else(||
( VFrameTs::max_value(), source )
);
let mut prod = ScldFrameProducer {
frame_ref: ScldFrameRef::new(screen0, frame_cache0, screen1, frame_cache1),
line,
next_source,
next_change_at,
source_changes,
source,
line_iter
};
prod.update_iter();
prod
}
pub fn swap_frame(&mut self, frame_ref: &mut ScldFrameRef<'a, V>) {
core::mem::swap(&mut self.frame_ref, frame_ref);
self.update_iter();
}
#[inline(always)]
pub fn peek_hts(&mut self) -> Ts {
col_hts(self.line_iter.column as i16)
}
#[inline(always)]
pub fn column(&mut self) -> usize {
self.line_iter.column
}
#[inline(always)]
pub fn line(&mut self) -> usize {
self.line
}
pub fn update_iter(&mut self) {
let line = self.line;
let source = self.source;
if source.is_second_screen() {
self.line_iter.ink_line = ink_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_pixels = &self.frame_ref.frame_cache1.frame_pixels[line];
}
else {
self.line_iter.ink_line = ink_line_from(line, self.frame_ref.screen0);
self.line_iter.frame_pixels = &self.frame_ref.frame_cache0.frame_pixels[line];
}
if source.is_hi_color() {
self.line_iter.attr_line = ink_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_colors = &self.frame_ref.frame_cache1.frame_pixels[line];
self.line_iter.frame_colors_coarse = EMPTY_FRAME_LINE;
}
else if source.is_second_screen() {
self.line_iter.attr_line = attr_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_colors = &self.frame_ref.frame_cache1.frame_colors[line];
self.line_iter.frame_colors_coarse = &self.frame_ref.frame_cache1.frame_colors_coarse[line >> 3];
}
else {
self.line_iter.attr_line = attr_line_from(line, self.frame_ref.screen0);
self.line_iter.frame_colors = &self.frame_ref.frame_cache0.frame_colors[line];
self.line_iter.frame_colors_coarse = &self.frame_ref.frame_cache0.frame_colors_coarse[line >> 3];
}
}
}
impl<'a, V, I> PlusVidFrameDataIterator for ScldFrameProducer<'a, V, I>
where V: VideoFrame,
I: Iterator<Item=VideoTsData2>
{
fn next_line(&mut self) {
let line = self.line + 1;
if line < PIXEL_LINES {
self.line = line;
self.update_iter();
self.line_iter.column = 0;
self.next_change_at.vc -= 1;
}
}
}
impl<'a, V, I> Iterator for ScldFrameProducer<'a, V, I>
where V: VideoFrame,
I: Iterator<Item=VideoTsData2>
{
type Item = (u8, u8, Ts);
fn next(&mut self) -> Option<Self::Item> {
let htc = col_hts(self.line_iter.column as i16);
while self.next_change_at.vc <= 0 {
if self.next_change_at.vc < 0 || self.next_change_at.hc < htc {
self.source = self.next_source;
self.update_iter();
if let Some((next_at, next_source)) = self.source_changes.next()
.map(|ts| vtm_next::<V>(ts, self.line as Ts)) {
self.next_change_at = next_at;
self.next_source = next_source;
}
else {
self.next_change_at = VFrameTs::max_value();
break;
}
}
else {
break;
}
}
self.line_iter.next()
.map(|(ink, attr)|
(ink, attr, htc)
)
}
}
#[inline(always)]
fn vtm_next<V: VideoFrame>(vtm: VideoTsData2, line: Ts) -> (VFrameTs<V>, SourceMode) {
let (mut vts, data): (VFrameTs<V>, u8) = vtm.into();
vts.vc -= V::VSL_PIXELS.start + line;
(vts, SourceMode::from_bits_truncate(data))
}
sourcepub const unsafe fn from_bits_unchecked(bits: u8) -> Self
pub const unsafe fn from_bits_unchecked(bits: u8) -> Self
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
Safety
The caller of the bitflags!
macro can chose to allow or
disallow extra bits for their bitflags type.
The caller of from_bits_unchecked()
has to ensure that
all bits correspond to a defined flag or that extra bits
are valid for this bitflags type.
sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true
if there are flags common to both self
and other
.
Examples found in repository?
More examples
sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true
if all of the flags in other
are contained within self
.
sourcepub fn insert(&mut self, other: Self)
pub fn insert(&mut self, other: Self)
Inserts the specified flags in-place.
Examples found in repository?
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
fn set_screen_mode(&mut self, mode: ScrMode) -> bool {
if self.ulaplus_disabled && mode != ScrMode::Classic(false) {
return false;
}
let mut render_mode = self.cur_render_mode;
let mut source_mode = self.cur_source_mode;
let color = match mode {
ScrMode::Classic(palette) => {
source_mode.remove(SourceMode::SOURCE_MASK);
render_mode.remove(RenderMode::COLOR_MODE|RenderMode::HI_RESOLUTION);
render_mode.set(RenderMode::PALETTE, palette);
self.ula.border_color().into()
}
ScrMode::HighColor(palette) => {
source_mode.remove(SourceMode::SOURCE_MASK);
source_mode.insert(SourceMode::ATTR_HI_COLOR);
render_mode.remove(RenderMode::COLOR_MODE|RenderMode::HI_RESOLUTION);
render_mode.set(RenderMode::PALETTE, palette);
self.ula.border_color().into()
}
ScrMode::HighRes(mode, palette) => {
source_mode.remove(SourceMode::SOURCE_MASK);
source_mode.insert(SourceMode::ATTR_HI_COLOR);
render_mode.remove(RenderMode::COLOR_MODE);
render_mode.insert(RenderMode::HI_RESOLUTION);
render_mode.set(RenderMode::PALETTE, palette);
mode >> 3
}
};
let vts = self.ula.current_video_ts();
self.update_source_mode(source_mode, vts);
self.update_render_mode(render_mode.with_color(color), vts);
true
}
sourcepub fn remove(&mut self, other: Self)
pub fn remove(&mut self, other: Self)
Removes the specified flags in-place.
Examples found in repository?
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
fn set_screen_mode(&mut self, mode: ScrMode) -> bool {
if self.ulaplus_disabled && mode != ScrMode::Classic(false) {
return false;
}
let mut render_mode = self.cur_render_mode;
let mut source_mode = self.cur_source_mode;
let color = match mode {
ScrMode::Classic(palette) => {
source_mode.remove(SourceMode::SOURCE_MASK);
render_mode.remove(RenderMode::COLOR_MODE|RenderMode::HI_RESOLUTION);
render_mode.set(RenderMode::PALETTE, palette);
self.ula.border_color().into()
}
ScrMode::HighColor(palette) => {
source_mode.remove(SourceMode::SOURCE_MASK);
source_mode.insert(SourceMode::ATTR_HI_COLOR);
render_mode.remove(RenderMode::COLOR_MODE|RenderMode::HI_RESOLUTION);
render_mode.set(RenderMode::PALETTE, palette);
self.ula.border_color().into()
}
ScrMode::HighRes(mode, palette) => {
source_mode.remove(SourceMode::SOURCE_MASK);
source_mode.insert(SourceMode::ATTR_HI_COLOR);
render_mode.remove(RenderMode::COLOR_MODE);
render_mode.insert(RenderMode::HI_RESOLUTION);
render_mode.set(RenderMode::PALETTE, palette);
mode >> 3
}
};
let vts = self.ula.current_video_ts();
self.update_source_mode(source_mode, vts);
self.update_render_mode(render_mode.with_color(color), vts);
true
}
sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Inserts or removes the specified flags depending on the passed value.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection between the flags in self
and
other
.
Specifically, the returned set contains only the flags which are
present in both self
and other
.
This is equivalent to using the &
operator (e.g.
ops::BitAnd
), as in flags & other
.
sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of between the flags in self
and other
.
Specifically, the returned set contains all flags which are
present in either self
or other
, including any which are
present in both (see Self::symmetric_difference
if that
is undesirable).
This is equivalent to using the |
operator (e.g.
ops::BitOr
), as in flags | other
.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference between the flags in self
and other
.
Specifically, the returned set contains all flags present in
self
, except for the ones present in other
.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other
(and this syntax is also supported).
This is equivalent to using the -
operator (e.g.
ops::Sub
), as in flags - other
.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference between the flags
in self
and other
.
Specifically, the returned set contains the flags present which
are present in self
or other
, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self
and other
.
This is equivalent to using the ^
operator (e.g.
ops::BitXor
), as in flags ^ other
.
sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self
, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all()
and self
(e.g. Self::all() - self
)
This is equivalent to using the !
operator (e.g.
ops::Not
), as in !flags
.
source§impl SourceMode
impl SourceMode
sourcepub fn from_scld_flags(flags: ScldCtrlFlags) -> SourceMode
pub fn from_scld_flags(flags: ScldCtrlFlags) -> SourceMode
Examples found in repository?
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
fn create_renderer<'a, 'r>(
&'a mut self,
border_size: BorderSize,
palette: &'r mut UlaPlusPalette
) -> RendererPlus<'r, ScldFrameProducer<'a, V, Drain<'a, VideoTsData2>>,
Drain<'a, VideoTsData6>,
Empty<PaletteChange>>
{
let render_mode = self.beg_render_mode();
let invert_flash = self.flash_state();
let screen0 = self.ula.memory.screen_ref(0).unwrap();
let screen1 = self.ula.memory.screen_ref(1).unwrap();
let frame_image_producer = ScldFrameProducer::new(
SourceMode::from_scld_flags(self.beg_ctrl_flags),
screen0, &self.ula.frame_cache,
screen1, &self.sec_frame_cache,
self.source_changes.drain(..));
RendererPlus {
render_mode,
palette,
frame_image_producer,
mode_changes: self.mode_changes.drain(..),
palette_changes: iter::empty(),
border_size,
invert_flash
}
}
More examples
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
fn set_ctrl_flags_value(&mut self, flags: ScldCtrlFlags, ts: VideoTs) {
let diff_flags = self.cur_ctrl_flags ^ flags;
// mmu
if self.mem_paged != 0 && diff_flags.is_map_ex_rom() {
let map_ex_rom = flags.is_map_ex_rom();
for page in 0..8u8 {
let mask = 1 << page;
if self.mem_paged & mask != 0 { // DOCK/EX-ROM
if map_ex_rom { // EX-ROM
self.ula.memory.map_rom_bank(8 + (page as usize) % (M::ROM_BANKS_MAX - 9), page)
}
else { // DOCK
self.ula.memory.map_rom_bank(page as usize, page)
}.unwrap();
}
}
}
// source mode
if diff_flags.intersects(ScldCtrlFlags::SCREEN_SOURCE_MASK) {
let source_mode = SourceMode::from_scld_flags(flags);
self.source_changes.push((ts, source_mode.bits()).into());
}
// render mode
if flags.is_screen_hi_res() {
if diff_flags.intersects(ScldCtrlFlags::SCREEN_HI_RES|ScldCtrlFlags::HIRES_COLOR_MASK) {
self.push_mode_change(ts,
RenderMode::with_color(
RenderMode::HI_RESOLUTION, flags.hires_color_index()));
}
}
else if diff_flags.is_screen_hi_res() {
self.push_mode_change(ts,
RenderMode::with_color(
RenderMode::empty(), self.ula.last_border.into()));
}
self.cur_ctrl_flags = flags;
}
sourcepub fn from_plus_reg_flags(flags: UlaPlusRegFlags) -> SourceMode
pub fn from_plus_reg_flags(flags: UlaPlusRegFlags) -> SourceMode
Examples found in repository?
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
pub fn enable_ulaplus_modes(&mut self, enable: bool) {
let ts = self.ula.current_video_ts();
self.ulaplus_disabled = !enable;
if enable {
let flags = self.scld_mode.into_plus_mode();
let render_mode = self.render_mode_from_plus_flags(flags)
.with_color_mode(self.color_mode);
self.update_render_mode(render_mode, ts);
self.update_source_mode(SourceMode::from_plus_reg_flags(flags), ts);
}
else if !enable {
let render_mode = RenderMode::from_border_color(self.ula.border_color());
self.update_render_mode(render_mode, ts);
self.update_source_mode(SourceMode::default(), ts);
}
}
/// Returns the current rendering mode.
pub fn render_mode(&self) -> RenderMode {
self.cur_render_mode
}
/// Returns the current source mode.
pub fn source_mode(&self) -> SourceMode {
self.cur_source_mode
}
/// Returns the current palette view.
pub fn ulaplus_palette(&self) -> &UlaPlusPalette {
&self.cur_palette
}
/// Returns the mutable reference to the current palette.
pub fn ulaplus_palette_mut(&mut self) -> &mut UlaPlusPalette {
&mut self.cur_palette
}
fn push_mode_change(&mut self, ts: VideoTs) {
self.mode_changes.push((ts, self.cur_render_mode.bits()).into());
}
fn update_render_mode(&mut self, render_mode: RenderMode, ts: VideoTs) {
if render_mode != self.cur_render_mode {
self.cur_render_mode = render_mode;
self.push_mode_change(ts);
}
}
fn update_source_mode(&mut self, source_mode: SourceMode, ts: VideoTs) {
let source_diff = source_mode ^ self.cur_source_mode;
if source_diff.intersects(SourceMode::SOURCE_MASK) {
self.source_changes.push((ts, source_mode.bits()).into());
}
if source_diff.intersects(SourceMode::SHADOW_BANK) {
self.ula.push_screen_change(ts);
}
self.cur_source_mode = source_mode;
}
#[inline]
fn change_border_color(&mut self, border: BorderColor, ts: VideoTs) {
if self.ula.update_last_border_color(border)
&& !self.cur_render_mode.is_hi_res()
{
self.cur_render_mode = self.cur_render_mode.with_color(border.into());
self.push_mode_change(ts);
}
}
fn render_mode_from_plus_flags(&self, flags: UlaPlusRegFlags) -> RenderMode {
if flags.is_screen_hi_res() {
(self.cur_render_mode | RenderMode::HI_RESOLUTION)
.with_color(flags.hires_color_index())
}
else {
(self.cur_render_mode & !RenderMode::HI_RESOLUTION)
.with_color(self.ula.border_color().into())
}
}
fn update_screen_mode(&mut self, flags: UlaPlusRegFlags, ts: VideoTs) {
self.update_source_mode(SourceMode::from_plus_reg_flags(flags), ts);
self.update_render_mode(self.render_mode_from_plus_flags(flags), ts);
}
sourcepub fn is_second_screen(self) -> bool
pub fn is_second_screen(self) -> bool
Examples found in repository?
More examples
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
pub fn update_iter(&mut self) {
let line = self.line;
let source = self.source;
if source.is_second_screen() {
self.line_iter.ink_line = ink_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_pixels = &self.frame_ref.frame_cache1.frame_pixels[line];
}
else {
self.line_iter.ink_line = ink_line_from(line, self.frame_ref.screen0);
self.line_iter.frame_pixels = &self.frame_ref.frame_cache0.frame_pixels[line];
}
if source.is_hi_color() {
self.line_iter.attr_line = ink_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_colors = &self.frame_ref.frame_cache1.frame_pixels[line];
self.line_iter.frame_colors_coarse = EMPTY_FRAME_LINE;
}
else if source.is_second_screen() {
self.line_iter.attr_line = attr_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_colors = &self.frame_ref.frame_cache1.frame_colors[line];
self.line_iter.frame_colors_coarse = &self.frame_ref.frame_cache1.frame_colors_coarse[line >> 3];
}
else {
self.line_iter.attr_line = attr_line_from(line, self.frame_ref.screen0);
self.line_iter.frame_colors = &self.frame_ref.frame_cache0.frame_colors[line];
self.line_iter.frame_colors_coarse = &self.frame_ref.frame_cache0.frame_colors_coarse[line >> 3];
}
}
sourcepub fn is_hi_color(self) -> bool
pub fn is_hi_color(self) -> bool
Examples found in repository?
21 22 23 24 25 26 27 28 29 30 31 32 33
fn get_screen_mode(&self) -> ScrMode {
let render_mode = self.cur_render_mode;
if render_mode.is_hi_res() {
let mode = ((render_mode & RenderMode::COLOR_MASK).bits() << 3) | 0b110;
ScrMode::HighRes(mode, render_mode.is_palette())
}
else if self.cur_source_mode.is_hi_color() {
ScrMode::HighColor(render_mode.is_palette())
}
else {
ScrMode::Classic(render_mode.is_palette())
}
}
More examples
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
pub fn update_iter(&mut self) {
let line = self.line;
let source = self.source;
if source.is_second_screen() {
self.line_iter.ink_line = ink_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_pixels = &self.frame_ref.frame_cache1.frame_pixels[line];
}
else {
self.line_iter.ink_line = ink_line_from(line, self.frame_ref.screen0);
self.line_iter.frame_pixels = &self.frame_ref.frame_cache0.frame_pixels[line];
}
if source.is_hi_color() {
self.line_iter.attr_line = ink_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_colors = &self.frame_ref.frame_cache1.frame_pixels[line];
self.line_iter.frame_colors_coarse = EMPTY_FRAME_LINE;
}
else if source.is_second_screen() {
self.line_iter.attr_line = attr_line_from(line, self.frame_ref.screen1);
self.line_iter.frame_colors = &self.frame_ref.frame_cache1.frame_colors[line];
self.line_iter.frame_colors_coarse = &self.frame_ref.frame_cache1.frame_colors_coarse[line >> 3];
}
else {
self.line_iter.attr_line = attr_line_from(line, self.frame_ref.screen0);
self.line_iter.frame_colors = &self.frame_ref.frame_cache0.frame_colors[line];
self.line_iter.frame_colors_coarse = &self.frame_ref.frame_cache0.frame_colors_coarse[line >> 3];
}
}
sourcepub fn is_shadow_bank(self) -> bool
pub fn is_shadow_bank(self) -> bool
Examples found in repository?
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
fn visible_screen_bank(&self) -> usize {
(self.cur_source_mode.is_shadow_bank() ^ self.ula.cur_screen_shadow()).into()
}
fn current_video_clock(&self) -> VFrameTsCounter<Self::VideoFrame, Self::Contention> {
self.ula.current_video_clock()
}
fn set_video_ts(&mut self, vts: VideoTs) {
self.ula.set_video_ts(vts);
}
fn flash_state(&self) -> bool {
self.ula.flash_state()
}
}
impl<'a, U> UlaPlus<U>
where U: UlaPlusInner<'a>
{
#[inline]
pub(super) fn update_frame_cache(&mut self, addr: u16, ts: VideoTs) {
let (frame_cache, memory_ref): (&mut UlaFrameCache<_>, _) = match addr {
0x4000..=0x5AFF => match self.ula.page1_screen0_shadow_bank() {
Some(false) => self.ula.frame_cache_mut_mem_ref(),
Some(true) => self.ula.shadow_frame_cache_mut_mem_ref(),
None => return
}
0x6000..=0x7AFF => match self.ula.page1_screen1_shadow_bank() {
Some(false) => (&mut self.sec_frame_cache, self.ula.memory_ref()),
Some(true) => (&mut self.shadow_sec_frame_cache, self.ula.memory_ref()),
None => return
}
0xC000..=0xDAFF => match self.ula.page3_screen0_shadow_bank() {
Some(false) => self.ula.frame_cache_mut_mem_ref(),
Some(true) => self.ula.shadow_frame_cache_mut_mem_ref(),
None => return
}
0xE000..=0xFAFF => match self.ula.page3_screen1_shadow_bank() {
Some(false) => (&mut self.sec_frame_cache, self.ula.memory_ref()),
Some(true) => (&mut self.shadow_sec_frame_cache, self.ula.memory_ref()),
None => return
}
_ => return
};
if addr & 0x1800 != 0x1800 {
let coords = pixel_address_coords(addr);
frame_cache.update_frame_pixels(memory_ref, coords, addr, ts);
}
else {
let coords = color_address_coords(addr);
frame_cache.update_frame_colors(memory_ref, coords, addr, ts);
}
}
// #[inline(always)]
// pub(super) fn update_snow_interference(&mut self, ts: VideoTs, ir: u16) {
// if self.ula.is_snow_interference(ir) {
// if let Some(coords) = U::VideoFrame::snow_interference_coords(ts) {
// let (screen0, frame_cache0,
// screen1, frame_cache1
// ) = if self.ula.cur_screen_shadow() ^ self.cur_source_mode.is_shadow_bank() {
// let (frame_cache0, memory) = self.ula.shadow_frame_cache_mut_mem_ref();
// (memory.screen_ref(1).unwrap(), frame_cache0,
// memory.screen_ref(3).unwrap(), self.shadow_sec_frame_cache)
// }
// else {
// let (frame_cache0, memory) = self.ula.frame_cache_mut_mem_ref();
// (memory.screen_ref(0).unwrap(), frame_cache0,
// memory.screen_ref(2).unwrap(), self.sec_frame_cache)
// };
// frame_cache0.apply_snow_interference(screen0, coords, ir as u8);
// frame_cache1.apply_snow_interference(screen1, coords, ir as u8);
// }
// }
// }
#[allow(clippy::type_complexity)]
fn create_renderer(
&'a mut self,
border_size: BorderSize,
) -> RendererPlus<'a,
PlusFrameProducer<'a,
U::VideoFrame,
Drain<'a, VideoTsData2>,
<U as UlaPlusInner<'a>>::ScreenSwapIter>,
Drain<'a, VideoTsData6>,
Drain<'a, PaletteChange>>
{
let invert_flash = self.ula.flash_state();
let render_mode = self.beg_render_mode;
let source_mode = self.beg_source_mode;
let swap_screens = source_mode.is_shadow_bank() ^ self.ula.beg_screen_shadow();
let VideoRenderDataView {
screen_changes,
memory,
frame_cache: frame_cache0,
frame_cache_shadow: frame_cache_shadow0
} = self.ula.video_render_data_view();
let (s0p0, s0p1, s1p0, s1p1) = match U::Memory::SCR_BANKS_MAX {
3 => (0, 1, 2, 3),
1 => (0, 0, 1, 1),
_ => panic!("unexpected number of screen banks")
};
let screen0 = memory.screen_ref(s0p0).unwrap();
let screen_shadow0 = memory.screen_ref(s0p1).unwrap();
let screen1 = memory.screen_ref(s1p0).unwrap();
let screen_shadow1 = memory.screen_ref(s1p1).unwrap();
let palette = &mut self.beg_palette;
let frame_cache1 = &mut self.sec_frame_cache;
let frame_cache_shadow1 = &mut self.shadow_sec_frame_cache;
let frame_image_producer = PlusFrameProducer::new(
swap_screens,
source_mode,
screen0, frame_cache0,
screen1, frame_cache1,
screen_shadow0, frame_cache_shadow0,
screen_shadow1, frame_cache_shadow1,
screen_changes,
self.source_changes.drain(..));
RendererPlus {
render_mode,
palette,
frame_image_producer,
mode_changes: self.mode_changes.drain(..),
palette_changes: self.palette_changes.drain(..),
border_size,
invert_flash
}
}
Trait Implementations§
source§impl Binary for SourceMode
impl Binary for SourceMode
source§impl BitAnd<SourceMode> for SourceMode
impl BitAnd<SourceMode> for SourceMode
source§impl BitAndAssign<SourceMode> for SourceMode
impl BitAndAssign<SourceMode> for SourceMode
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
Disables all flags disabled in the set.
source§impl BitOr<SourceMode> for SourceMode
impl BitOr<SourceMode> for SourceMode
source§fn bitor(self, other: SourceMode) -> Self
fn bitor(self, other: SourceMode) -> Self
Returns the union of the two sets of flags.
§type Output = SourceMode
type Output = SourceMode
|
operator.source§impl BitOrAssign<SourceMode> for SourceMode
impl BitOrAssign<SourceMode> for SourceMode
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Adds the set of flags.
source§impl BitXor<SourceMode> for SourceMode
impl BitXor<SourceMode> for SourceMode
source§impl BitXorAssign<SourceMode> for SourceMode
impl BitXorAssign<SourceMode> for SourceMode
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
Toggles the set of flags.
source§impl Clone for SourceMode
impl Clone for SourceMode
source§fn clone(&self) -> SourceMode
fn clone(&self) -> SourceMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SourceMode
impl Debug for SourceMode
source§impl Default for SourceMode
impl Default for SourceMode
source§fn default() -> SourceMode
fn default() -> SourceMode
source§impl<'de> Deserialize<'de> for SourceMode
impl<'de> Deserialize<'de> for SourceMode
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Extend<SourceMode> for SourceMode
impl Extend<SourceMode> for SourceMode
source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl From<SourceMode> for u8
impl From<SourceMode> for u8
source§fn from(mode: SourceMode) -> u8
fn from(mode: SourceMode) -> u8
source§impl From<VideoTsData2> for SourceMode
impl From<VideoTsData2> for SourceMode
source§fn from(vtsm: VideoTsData2) -> Self
fn from(vtsm: VideoTsData2) -> Self
source§impl FromIterator<SourceMode> for SourceMode
impl FromIterator<SourceMode> for SourceMode
source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
source§impl Hash for SourceMode
impl Hash for SourceMode
source§impl LowerHex for SourceMode
impl LowerHex for SourceMode
source§impl Not for SourceMode
impl Not for SourceMode
source§impl Octal for SourceMode
impl Octal for SourceMode
source§impl Ord for SourceMode
impl Ord for SourceMode
source§fn cmp(&self, other: &SourceMode) -> Ordering
fn cmp(&self, other: &SourceMode) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<SourceMode> for SourceMode
impl PartialEq<SourceMode> for SourceMode
source§fn eq(&self, other: &SourceMode) -> bool
fn eq(&self, other: &SourceMode) -> bool
source§impl PartialOrd<SourceMode> for SourceMode
impl PartialOrd<SourceMode> for SourceMode
source§fn partial_cmp(&self, other: &SourceMode) -> Option<Ordering>
fn partial_cmp(&self, other: &SourceMode) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for SourceMode
impl Serialize for SourceMode
source§impl Sub<SourceMode> for SourceMode
impl Sub<SourceMode> for SourceMode
source§impl SubAssign<SourceMode> for SourceMode
impl SubAssign<SourceMode> for SourceMode
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Disables all flags enabled in the set.
source§impl TryFrom<u8> for SourceMode
impl TryFrom<u8> for SourceMode
source§impl UpperHex for SourceMode
impl UpperHex for SourceMode
impl Copy for SourceMode
impl Eq for SourceMode
impl StructuralEq for SourceMode
impl StructuralPartialEq for SourceMode
Auto Trait Implementations§
impl RefUnwindSafe for SourceMode
impl Send for SourceMode
impl Sync for SourceMode
impl Unpin for SourceMode
impl UnwindSafe for SourceMode
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
source§fn into_sample(self) -> S
fn into_sample(self) -> S
S
a sample type from self
.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more