Class: Amaterasu::GameBoy::Ppu::Modes::Rendering::PixelEmitter
- Inherits:
-
Object
- Object
- Amaterasu::GameBoy::Ppu::Modes::Rendering::PixelEmitter
- Defined in:
- lib/amaterasu/game_boy/ppu/modes/rendering/pixel_emitter.rb
Overview
Responsible for emitting pixels from the Pixel FIFO to the Display.
Constant Summary collapse
- PIXELS_PER_SCANLINE =
160
Instance Method Summary collapse
-
#initialize(ppu, bg_win_fifo, sprite_fifo) ⇒ PixelEmitter
constructor
A new instance of PixelEmitter.
- #reset_for_scanline ⇒ Object
-
#tick? ⇒ Boolean
Called each T-cycle.
- #to_s ⇒ Object
Constructor Details
#initialize(ppu, bg_win_fifo, sprite_fifo) ⇒ PixelEmitter
Returns a new instance of PixelEmitter.
12 13 14 15 16 17 18 19 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/pixel_emitter.rb', line 12 def initialize(ppu, bg_win_fifo, sprite_fifo) @ppu = ppu @bg_win_fifo = bg_win_fifo @sprite_fifo = sprite_fifo @pixels_discarded = 0 @pixels_emitted = 0 end |
Instance Method Details
#reset_for_scanline ⇒ Object
38 39 40 41 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/pixel_emitter.rb', line 38 def reset_for_scanline @pixels_emitted = 0 @pixels_discarded = 0 end |
#tick? ⇒ Boolean
Called each T-cycle.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/pixel_emitter.rb', line 22 def tick? return false if @bg_win_fifo.empty? return false unless @pixels_emitted < PIXELS_PER_SCANLINE @popped_sprite_pixel = @sprite_fifo.pop_pixel @popped_bg_win_pixel = @bg_win_fifo.pop_pixel shaded_priority_pixel = define_pixel_priority # TODO: Implement framebuffer fixed size [lcd_y * width + lcd_x] @ppu.framebuffer << shaded_priority_pixel @pixels_emitted += 1 true end |
#to_s ⇒ Object
43 44 45 46 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/pixel_emitter.rb', line 43 def to_s "BG WIN FIFO: #{@bg_win_fifo.pixels} | " \ "Popped: #{@popped_pixel} (##{format('%d', @pixels_discarded)})" end |