Class: Amaterasu::GameBoy::Ppu::Modes::Rendering::SpriteFetcher
- Inherits:
-
Object
- Object
- Amaterasu::GameBoy::Ppu::Modes::Rendering::SpriteFetcher
- Defined in:
- lib/amaterasu/game_boy/ppu/modes/rendering/sprite_fetcher.rb
Overview
Responsible for fetching Sprites tiles, decoding Sprite pixels and outputting them into the Sprite FIFO.
Defined Under Namespace
Classes: SpritePixel
Constant Summary collapse
- BIT_MASK_BG_WIN_PRIORITY_SET =
1 << 3
- BIT_MASK_USE_OBP1_PALETTE =
1 << 2
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(ppu, sprite_fifo) ⇒ SpriteFetcher
constructor
A new instance of SpriteFetcher.
- #start_for(sprite) ⇒ Object
-
#tick ⇒ Object
Core fetch state machine (Takes 2 dots per step).
Constructor Details
#initialize(ppu, sprite_fifo) ⇒ SpriteFetcher
Returns a new instance of SpriteFetcher.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/sprite_fetcher.rb', line 16 def initialize(ppu, sprite_fifo) @ppu = ppu @sprite_fifo = sprite_fifo @step = :fetch_tile_index @completed = false @fetch_duration = 6 @current_sprite = nil @tile_index = nil @tile_data_low = nil @tile_data_high = nil @tile_pixels = nil @encoded_pixels = Array.new(8) end |
Instance Method Details
#done? ⇒ Boolean
50 51 52 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/sprite_fetcher.rb', line 50 def done? @completed end |
#start_for(sprite) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/sprite_fetcher.rb', line 33 def start_for(sprite) @current_sprite = sprite @step = :fetch_tile_index @completed = false @fetch_duration = 6 end |
#tick ⇒ Object
Core fetch state machine (Takes 2 dots per step).
42 43 44 45 46 47 48 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/sprite_fetcher.rb', line 42 def tick case @step when :fetch_tile_index then fetch_tile_index when :fetch_tile_data_low then fetch_tile_data_low when :fetch_tile_data_high then fetch_tile_data_high end end |