Skip to content

Instantly share code, notes, and snippets.

@lhz
Last active December 18, 2015 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lhz/5748054 to your computer and use it in GitHub Desktop.
Save lhz/5748054 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'bundler/setup'
require 'c64'
require 'c64/prototype'
class BallTest < C64::Prototype
border :black
screen :white
framedump :path => 'tmp', :count => 128
def init
@data = File.read('data.bin').bytes[2..-1]
@dpos = 0
end
def draw
while @data[@dpos] != 0xFF
x1, y1, x2, y2, x3, y3, x4, y4 = @data[@dpos, 8]
x1 &= 0x7F
points = [[x1, y1], [x2, y2], [x3, y3]]
points << [x4, y4] if x4 < 0x80
polygon :points => points.map {|x, y| [x + 96, y + 36]}, :fill => :red
@dpos += 2 * points.size
end
@dpos = (@dpos + 1) % @data.size
end
end
BallTest.run
@lhz
Copy link
Author

lhz commented Jun 23, 2013

Needs a Gemfile including the following line:

gem 'c64-ruby', :github => 'lhz/c64-ruby'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment