Class: Amaterasu::GameBoy::Vram::TileData
- Inherits:
-
Object
- Object
- Amaterasu::GameBoy::Vram::TileData
- Defined in:
- lib/amaterasu/game_boy/vram/tile_data.rb
Overview
Models the Tile Data that lives in the VRAM.
Constant Summary collapse
- TILE_SIZE =
16- TILE_ENTRIES =
384
Instance Attribute Summary collapse
-
#addressing_mode ⇒ Object
Returns the value of attribute addressing_mode.
-
#base_offset ⇒ Object
readonly
Returns the value of attribute base_offset.
-
#tiles ⇒ Object
readonly
Returns the value of attribute tiles.
Instance Method Summary collapse
-
#initialize(vram_data:) ⇒ TileData
constructor
A new instance of TileData.
-
#tile_at(tile_index) ⇒ Vram::Tile
Fetches a Tile based on a given index, if the addressing mode is set to :signed, we need to sign the value before fetching the tile.
Constructor Details
#initialize(vram_data:) ⇒ TileData
Returns a new instance of TileData.
14 15 16 17 18 19 20 21 |
# File 'lib/amaterasu/game_boy/vram/tile_data.rb', line 14 def initialize(vram_data:) @addressing_mode = :unsigned @base_offset = 0x0000 @tiles = Array.new(TILE_ENTRIES) do |index| Tile.new(vram_data: vram_data, tile_index: index) end end |
Instance Attribute Details
#addressing_mode ⇒ Object
Returns the value of attribute addressing_mode.
11 12 13 |
# File 'lib/amaterasu/game_boy/vram/tile_data.rb', line 11 def addressing_mode @addressing_mode end |
#base_offset ⇒ Object (readonly)
Returns the value of attribute base_offset.
11 12 13 |
# File 'lib/amaterasu/game_boy/vram/tile_data.rb', line 11 def base_offset @base_offset end |
#tiles ⇒ Object (readonly)
Returns the value of attribute tiles.
11 12 13 |
# File 'lib/amaterasu/game_boy/vram/tile_data.rb', line 11 def tiles @tiles end |
Instance Method Details
#tile_at(tile_index) ⇒ Vram::Tile
Fetches a Tile based on a given index, if the addressing mode is set to :signed, we need to sign the value before fetching the tile.
35 36 37 38 39 40 |
# File 'lib/amaterasu/game_boy/vram/tile_data.rb', line 35 def tile_at(tile_index) tile_index = sign_value(tile_index) if @addressing_mode == :signed tile_offset = @base_offset / Tile::SIZE_IN_BYTES @tiles[tile_offset + tile_index] end |