Class: Burn::Generator::Rom::AssemblyMusic

Inherits:
Object
  • Object
show all
Includes:
Debug
Defined in:
lib/burn/generator/rom/assembly_music.rb

Instance Method Summary collapse

Methods included from Debug

#log

Constructor Details

#initialize(workspace_root) ⇒ AssemblyMusic

Returns a new instance of AssemblyMusic.



7
8
9
10
11
12
13
14
15
16
# File 'lib/burn/generator/rom/assembly_music.rb', line 7

def initialize(workspace_root)
  # Generic
  @workspace_root = workspace_root
  
  # Music related
  @resources = {}
  
  #@channels = Array.new
  
end

Instance Method Details

#generateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/burn/generator/rom/assembly_music.rb', line 22

def generate
  # prepare music.s - music assembler file
  File.write(
    "#{@workspace_root}/tmp/burn/asset/music.s", 
    File.read("#{@workspace_root}/tmp/burn/asset/music.s")
      .gsub(/__@__EXPORT__@__/, @resources.keys.map{|p| "	.export _music_#{p}"}.join("\n"))
      .gsub(/__@__INCLUDE__@__/, @resources.keys.map{|p| "_music_#{p}: 		.include \"mus_#{p}.s\""}.join("\n"))
  )
  
  # preparing each song file
  @resources.each {|resource_name, channels|
    # prepare other music resources
    File.write( "#{@workspace_root}/tmp/burn/asset/mus_#{resource_name}.s",
      File.read(File.dirname(__FILE__)+"/template/mus_template.s")
        .gsub(/__@__NAME__@__/, resource_name)
        .gsub(/__@__CHANNEL1__@__/, channels.shift || "")
        .gsub(/__@__CHANNEL2__@__/, channels.shift || "")
        .gsub(/__@__CHANNEL3__@__/, channels.shift || "")
        .gsub(/__@__CHANNEL4__@__/, channels.shift || "")
        .gsub(/__@__CHANNEL5__@__/, channels.shift || "")
    )
  }

end

#get_contextObject



18
19
20
# File 'lib/burn/generator/rom/assembly_music.rb', line 18

def get_context
  self
end