pub fn step(&mut self) {

        if !self.enabled {
            return;
        }

        self.htick = (self.htick + 1) % timings::HTOTAL;

        let cur_mode = self.mode;

        let new_mode =
            if cur_mode == Mode::VBlank {
                if self.htick == 0 {
                    self.line = (self.line + 1) % timings::VTOTAL;

                    if self.line == 0 {
                        Mode::Prelude
                    } else {
                        cur_mode
                    }
                } else {
                    cur_mode
                }
            } else {
                match self.htick {
                    0 => {
                        // New line
                        self.line += 1;
                        if self.line == timings::VSYNC_ON {
                            // We're entering vertical blanking, we're
                            // done drawing the current frame
                            self.it_vblank = true;
                            self.display.flip();
                            Mode::VBlank
                        } else {
                            Mode::Prelude
                        }
                    }
                    timings::HACTIVE_ON => Mode::Active,
                    timings::HSYNC_ON   => Mode::HBlank,
                    _                   => cur_mode,
                }
            };

        self.mode = new_mode;

        // Compute at which cycle the first pixel will actually be
        // output on the screen. I don't know where this comes from
        // but it's what GearBoy seems to use. Using 48 for the first
        // line messes up The Legend of Zelda's intro.
        let line_start = timings::HACTIVE_ON +
            match self.line {
                0 => 160,
                _ => 48,
            };

        if self.htick == line_start && self.mode != Mode::VBlank {
            // It's time to draw the current line

            let y = self.line;

            for x in 0u8..160 {
                self.render_pixel(x, y);
            }
        }
        self.update_ldc_interrupt();
    }
/// Called at each tick of the system clock. Move the emulated
/// state one step forward.
Called at each tick of the system clock. Move the emulated
state one step forward.
Called at each tick of the system clock . Move the emulated state one step forward .
pub fn step(&mut self) {
        if !self.enabled {
            return;
        }
        self.htick = (self.htick + 1) % timings::HTOTAL;
        let cur_mode = self.mode;
        let new_mode =
            if cur_mode == Mode::VBlank {
                if self.htick == 0 {
                    self.line = (self.line + 1) % timings::VTOTAL;
                    if self.line == 0 {
                        Mode::Prelude
                    } else {
                        cur_mode
                    }
                } else {
                    cur_mode
                }
            } else {
                match self.htick {
                    0 => {
                        // New line
                        self.line += 1;
                        if self.line == timings::VSYNC_ON {
                            // We're entering vertical blanking, we're
                            // done drawing the current frame
                            self.it_vblank = true;
                            self.display.flip();
                            Mode::VBlank
                        } else {
                            Mode::Prelude
                        }
                    }
                    timings::HACTIVE_ON => Mode::Active,
                    timings::HSYNC_ON   => Mode::HBlank,
                    _                   => cur_mode,
                }
            };
        self.mode = new_mode;
        // Compute at which cycle the first pixel will actually be
        // output on the screen. I don't know where this comes from
        // but it's what GearBoy seems to use. Using 48 for the first
        // line messes up The Legend of Zelda's intro.
        let line_start = timings::HACTIVE_ON +
            match self.line {
                0 => 160,
                _ => 48,
            };
        if self.htick == line_start && self.mode != Mode::VBlank {
            // It's time to draw the current line
            let y = self.line;
            for x in 0u8..160 {
                self.render_pixel(x, y);
            }
        }
        self.update_ldc_interrupt();
    }
pub fn step ( & mut self ) { if ! self . enabled { return ; } self . htick = ( self . htick + 1 ) % timings :: HTOTAL ; let cur_mode = self . mode ; let new_mode = if cur_mode == Mode :: VBlank { if self . htick == 0 { self . line = ( self . line + 1 ) % timings :: VTOTAL ; if self . line == 0 { Mode :: Prelude } else { cur_mode } } else { cur_mode } } else { match self . htick { 0 => { // New line self . line += 1 ; if self . line == timings :: VSYNC_ON { // We're entering vertical blanking, we're // done drawing the current frame self . it_vblank = true ; self . display . flip ( ) ; Mode :: VBlank } else { Mode :: Prelude } } timings :: HACTIVE_ON => Mode :: Active , timings :: HSYNC_ON => Mode :: HBlank , _ => cur_mode , } } ; self . mode = new_mode ; // Compute at which cycle the first pixel will actually be // output on the screen. I don't know where this comes from // but it's what GearBoy seems to use. Using 48 for the first // line messes up The Legend of Zelda's intro. let line_start = timings :: HACTIVE_ON + match self . line { 0 => 160 , _ => 48 , } ; if self . htick == line_start && self . mode != Mode :: VBlank { // It's time to draw the current line let y = self . line ; for x in 0u8 .. 160 { self . render_pixel ( x , y ) ; } } self . update_ldc_interrupt ( ) ; }
Called at each tick of the system clock.
Called at each tick of the system clock .
&mut self
&mut self