Skip to content

Commit

Permalink
Fix PPU object attribute scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
r7kamura committed Nov 14, 2018
1 parent 989f733 commit e726b16
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/rnes/ppu.rb
Expand Up @@ -435,22 +435,27 @@ def x

# @return [Integer]
def x_in_tile
x % TILE_WIDTH
x_with_scroll % TILE_WIDTH
end

# @return [Integer]
def x_of_block
x / BLOCK_WIDTH
x_with_scroll / BLOCK_WIDTH
end

# @return [Integer]
def x_of_encoded_attributes
x / ENCODED_ATTRIBUTES_WIDTH
x_with_scroll / ENCODED_ATTRIBUTES_WIDTH
end

# @return [Integer]
def x_of_tile
(x + @registers.scroll_x) / TILE_WIDTH
x_with_scroll / TILE_WIDTH
end

# @return [Integer]
def x_with_scroll
x + @registers.scroll_x
end

# @return [Integer]
Expand All @@ -460,22 +465,27 @@ def y

# @return [Integer]
def y_in_tile
y % TILE_HEIGHT
y_with_scroll % TILE_HEIGHT
end

# @return [Integer]
def y_of_block
y / BLOCK_HEIGHT
y_with_scroll / BLOCK_HEIGHT
end

# @return [Integer]
def y_of_encoded_attributes
y / ENCODED_ATTRIBUTES_HEIGHT
y_with_scroll / ENCODED_ATTRIBUTES_HEIGHT
end

# @return [Integer]
def y_of_tile
(y + @registers.scroll_y) / TILE_HEIGHT
y_with_scroll / TILE_HEIGHT
end

# @return [Integer]
def y_with_scroll
y + @registers.scroll_y
end
end
end

0 comments on commit e726b16

Please sign in to comment.