Class: Amaterasu::GameBoy::Ppu::Modes::Rendering::BgWinFetcher
- Inherits:
-
Object
- Object
- Amaterasu::GameBoy::Ppu::Modes::Rendering::BgWinFetcher
- Defined in:
- lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb
Overview
Responsible for fetching Background and Window tiles, decoding the pixels and outputting them into the BG/WIN FIFO.
Despite the similarity it behaves differently than the SpriteFetcher.
Instance Attribute Summary collapse
-
#fetch_mode ⇒ Object
readonly
Returns the value of attribute fetch_mode.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
- #activate_window! ⇒ Object
- #increment_window_y ⇒ Object
-
#initialize(ppu, bg_win_fifo) ⇒ BgWinFetcher
constructor
A new instance of BgWinFetcher.
- #reset_for_scanline ⇒ Object
-
#tick ⇒ Object
Core fetch state machine.
Constructor Details
#initialize(ppu, bg_win_fifo) ⇒ BgWinFetcher
Returns a new instance of BgWinFetcher.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 15 def initialize(ppu, bg_win_fifo) @ppu = ppu @bg_win_fifo = bg_win_fifo @step = :fetch_tile_index @bg_fetcher_x = 0 @window_fetcher_x = 0 @fetch_mode = :bg @fetch_duration = 6 @sleep_duration = 2 @warming_up = true @tile_index = nil @tile_data_low = nil @tile_data_high = nil @tile_pixels = nil end |
Instance Attribute Details
#fetch_mode ⇒ Object (readonly)
Returns the value of attribute fetch_mode.
13 14 15 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 13 def fetch_mode @fetch_mode end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
13 14 15 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 13 def step @step end |
Instance Method Details
#activate_window! ⇒ Object
46 47 48 49 50 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 46 def activate_window! @bg_win_fifo.clear @fetch_mode = :window reset_cycle end |
#increment_window_y ⇒ Object
52 53 54 55 56 57 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 52 def increment_window_y return unless @window_drawed @ppu.window_y_count += 1 @window_drawed = false end |
#reset_for_scanline ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 59 def reset_for_scanline reset_cycle @fetch_mode = :bg @warming_up = true @bg_fetcher_x = 0 @window_fetcher_x = 0 increment_window_y end |
#tick ⇒ Object
Core fetch state machine.
36 37 38 39 40 41 42 43 44 |
# File 'lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb', line 36 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 when :push then push when :sleep then sleep end end |