Class: Burn::Generator::Rom::AssemblySoundEffect

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debug

#log

Constructor Details

#initialize(workspace_root) ⇒ AssemblySoundEffect

Returns a new instance of AssemblySoundEffect.



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

def initialize(workspace_root)
  # Generic
  @workspace_root = workspace_root
  
  # Music related
  @resources = {}
  
end

Instance Attribute Details

#resourcesObject (readonly)

Returns the value of attribute resources.



6
7
8
# File 'lib/burn/generator/rom/assembly_sound_effect.rb', line 6

def resources
  @resources
end

Instance Method Details

#generateObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/burn/generator/rom/assembly_sound_effect.rb', line 21

def generate
  # prepare sound.s - sound effect assembler file
  File.write(
    "#{@workspace_root}/tmp/burn/asset/sounds.s", 
    "sounds:\n" \
      + @resources.keys.map{|p| "	.word @#{p}"}.join("\n") \
      + "\n" \
      + @resources.map{|key,value| "@#{key}:\n#{value.join}	.byte $ff\n" }.join
  )
  
end

#get_contextObject



17
18
19
# File 'lib/burn/generator/rom/assembly_sound_effect.rb', line 17

def get_context
  self
end