Sha256: e98700c33fa7cc1399f35a39d6b49ff8c1bdc8d0ea72cf9355928f16a7f7a48c

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

module Rubygb
  def self.build filename, options={}
    unless File.exists? filename
      raise "Fatal: can't find #{filename}"
    end

    if options[:output]
      Dir.mkdir(options[:output]) unless Dir.exists? options[:output]
    end

    base = File.basename(filename, ".*")
    exe_path = File.expand_path(File.join(File.dirname(__FILE__),"..","rgbds"))

    obj_file, map_file, sym_file, rom_file = %w(.obj .map .sym .gb).map do |ext|
      options[:output] ? File.join(options[:output], "#{base}#{ext}") : "#{base}#{ext}"
    end

    raise "Assembly failed!" unless system("#{exe_path}/rgbasm -v -o#{obj_file} #{filename}")

    raise "Link failed!" unless system("#{exe_path}/rgblink -m#{map_file} -n#{sym_file} -o#{rom_file} #{obj_file}")

    unless options[:no_fix]
      raise "Header fix failed!" unless system("#{exe_path}/rgbfix -p0 -v #{rom_file}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubygb-0.2.2 lib/rubygb/rubygb.rb