Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loop unrolling on Ruby2600 Tia.rb
def draw_scanline
scanline = Array.new(160, 0)
unroll_count = 16
loop_count = VISIBLE_CLK_COUNT/unroll_count
pixel = 0
while loop_count > 0
draw_pixel(pixel, scanline)
draw_pixel(pixel+1, scanline)
draw_pixel(pixel+2, scanline)
draw_pixel(pixel+3, scanline)
draw_pixel(pixel+4, scanline)
draw_pixel(pixel+5, scanline)
draw_pixel(pixel+6, scanline)
draw_pixel(pixel+7, scanline)
draw_pixel(pixel+8, scanline)
draw_pixel(pixel+9, scanline)
draw_pixel(pixel+10, scanline)
draw_pixel(pixel+11, scanline)
draw_pixel(pixel+12, scanline)
draw_pixel(pixel+13, scanline)
draw_pixel(pixel+14, scanline)
draw_pixel(pixel+15, scanline)
loop_count -= unroll_count
pixel += unroll_count
end
scanline
end
def draw_pixel(pixel, scanline)
@scanline_stage = @late_reset_hblank && pixel < 8 ? :late_hblank : :visible
update_collision_flags
sync_2600_with pixel + HORIZONTAL_BLANK_CLK_COUNT
scanline[pixel] = topmost_pixel if @scanline_stage == :visible && !vertical_blank?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.