burn 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +56 -569
- data/lib/burn.rb +5 -3
- data/lib/burn/cli.rb +160 -199
- data/lib/burn/config.rb +4 -0
- data/lib/burn/config/app.rb +15 -0
- data/lib/burn/config/config_base.rb +16 -0
- data/lib/burn/config/loader.rb +23 -0
- data/lib/burn/config/server.rb +11 -0
- data/lib/burn/fuel.rb +11 -0
- data/lib/burn/{dsl → fuel}/dsl_base.rb +1 -1
- data/lib/burn/fuel/rom/channel_stream.rb +106 -0
- data/lib/burn/fuel/rom/declare.rb +43 -0
- data/lib/burn/fuel/rom/music.rb +37 -0
- data/lib/burn/fuel/rom/note.rb +126 -0
- data/lib/burn/fuel/rom/scene.rb +279 -0
- data/lib/burn/fuel/rom/sound.rb +31 -0
- data/lib/burn/fuel/rom/sound_effect.rb +92 -0
- data/lib/burn/fuel/telnet/declare.rb +26 -0
- data/lib/burn/fuel/telnet/scene.rb +112 -0
- data/lib/burn/generator.rb +10 -3
- data/lib/burn/generator/rom/assembly_music.rb +49 -0
- data/lib/burn/generator/rom/assembly_sound_effect.rb +35 -0
- data/lib/burn/generator/rom/c_source.rb +55 -0
- data/lib/burn/generator/{template → rom/template}/mus_template.s +0 -0
- data/lib/burn/generator/{template → rom/template}/template.c +0 -0
- data/lib/burn/generator/rom_builder.rb +67 -0
- data/lib/burn/generator/telnet/jit_compiler.rb +41 -0
- data/lib/burn/generator/telnet/screen.rb +86 -0
- data/lib/burn/generator/telnet/sprite.rb +16 -0
- data/lib/burn/generator/telnet/user_input.rb +25 -0
- data/lib/burn/generator/telnet_vm.rb +50 -0
- data/lib/burn/pxes.rb +3 -0
- data/lib/burn/{util/pxes.rb → pxes/cc65_transpiler.rb} +8 -14
- data/lib/burn/pxes/cruby_transpiler.rb +189 -0
- data/lib/burn/pxes/transpiler_base.rb +14 -0
- data/lib/burn/server.rb +2 -0
- data/lib/burn/server/rom.rb +24 -0
- data/lib/burn/server/telnet.rb +120 -0
- data/lib/burn/util.rb +1 -2
- data/lib/burn/util/logo.rb +68 -0
- data/lib/burn/util/os.rb +1 -1
- data/lib/burn/version.rb +1 -1
- metadata +53 -19
- data/lib/burn/builder.rb +0 -65
- data/lib/burn/dsl.rb +0 -8
- data/lib/burn/dsl/channel_stream.rb +0 -105
- data/lib/burn/dsl/declare.rb +0 -42
- data/lib/burn/dsl/music.rb +0 -36
- data/lib/burn/dsl/note.rb +0 -125
- data/lib/burn/dsl/scene.rb +0 -278
- data/lib/burn/dsl/sound.rb +0 -30
- data/lib/burn/dsl/sound_effect.rb +0 -91
- data/lib/burn/generator/assembly_music.rb +0 -47
- data/lib/burn/generator/assembly_sound_effect.rb +0 -33
- data/lib/burn/generator/c_source.rb +0 -54
- data/lib/burn/util/server.rb +0 -21
data/lib/burn/dsl/sound.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Burn
|
2
|
-
module Dsl
|
3
|
-
class Sound < DslBase
|
4
|
-
def initialize(resource_name, context)
|
5
|
-
super(resource_name, context)
|
6
|
-
|
7
|
-
if resource_name.nil? then
|
8
|
-
raise Exception.new "Resource name for Sound class must be provided."
|
9
|
-
else
|
10
|
-
@resource_name = resource_name
|
11
|
-
end
|
12
|
-
|
13
|
-
@context.instance_exec resource_name, &lambda{|resource_name|
|
14
|
-
@resources["#{resource_name}"] = Array.new
|
15
|
-
}
|
16
|
-
|
17
|
-
@se = SoundEffect.new
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def effect(&block)
|
22
|
-
@context.instance_exec(@resource_name,@se) do |resource_name,se|
|
23
|
-
se.load(&block)
|
24
|
-
@resources["#{resource_name}"] << se.generate
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
module Burn
|
2
|
-
module Dsl
|
3
|
-
class SoundEffect
|
4
|
-
# duty cycle: 00�F12.5%�@01�F25%�@10�F50%�@11�F75%
|
5
|
-
LOWEST = 0
|
6
|
-
LOWER = 1
|
7
|
-
HIGHER = 2
|
8
|
-
HIGHEST = 3
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@output_buffer = Array.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def load(&block)
|
15
|
-
self.instance_eval &block
|
16
|
-
end
|
17
|
-
|
18
|
-
# $4000 related
|
19
|
-
def duty_cycle(ratio)
|
20
|
-
@duty_cycle = SoundEffect.const_get(ratio.upcase)
|
21
|
-
end
|
22
|
-
|
23
|
-
def velocity(level)
|
24
|
-
@velocity = level
|
25
|
-
end
|
26
|
-
|
27
|
-
def envelope_decay(flag)
|
28
|
-
@envelope_decay = flag==:enable ? 0 : 1
|
29
|
-
end
|
30
|
-
|
31
|
-
def envelope_decay_loop(flag)
|
32
|
-
@envelope_decay_loop = flag==:enable ? 1 : 0
|
33
|
-
end
|
34
|
-
|
35
|
-
def length_counter_clock(flag)
|
36
|
-
@envelope_decay_loop = flag==:enable ? 0 : 1
|
37
|
-
end
|
38
|
-
|
39
|
-
# $4001 related
|
40
|
-
def pitch(i)
|
41
|
-
@pitch = i
|
42
|
-
end
|
43
|
-
|
44
|
-
def length(i)
|
45
|
-
@length = i + 15
|
46
|
-
end
|
47
|
-
|
48
|
-
alias_method :envelope_decay_rate, :velocity
|
49
|
-
alias_method :volume, :velocity
|
50
|
-
alias_method :envelope, :envelope_decay
|
51
|
-
alias_method :envelope_loop, :envelope_decay_loop
|
52
|
-
alias_method :key_off_counter, :length_counter_clock
|
53
|
-
|
54
|
-
def generate
|
55
|
-
if !@duty_cycle.nil? || !@velocity.nil? || @envelope_decay.nil? || @envelope_decay_loop.nil? then
|
56
|
-
@duty_cycle = HIGHER if !@duty_cycle.nil?
|
57
|
-
@velocity = 7 if @velocity.nil?
|
58
|
-
@envelope_decay = 0 if @envelope_decay.nil?
|
59
|
-
@envelope_decay_loop = 0 if @envelope_decay_loop.nil?
|
60
|
-
|
61
|
-
reg = @duty_cycle*64 + @envelope_decay*32 + @envelope_decay_loop*16 + @velocity
|
62
|
-
if @reg4000 != reg then
|
63
|
-
@output_buffer << " .byte $00,$%02x" % reg
|
64
|
-
@reg4000 = reg
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
if !@pitch.nil? then
|
69
|
-
if @reg4001 != @pitch then
|
70
|
-
@output_buffer << " .byte $01,$%02x" % @pitch
|
71
|
-
@reg4001 = @pitch
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
@length = 16 if @length.nil?
|
76
|
-
@output_buffer << " .byte $%02x" % @length
|
77
|
-
|
78
|
-
# return result
|
79
|
-
@output_buffer.join("\n") + "\n"
|
80
|
-
|
81
|
-
#" .byte $00,$7f\n .byte $01,$ab\n .byte $02,$01\n .byte $13\n .byte $01,$3f\n .byte $39\n .byte $01,$1c\n .byte $13\n .byte $ff\n"
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
def __translate
|
86
|
-
" .byte " + @notes.map{|p| "$%02x" % p}.join(",")
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Burn
|
2
|
-
module Generator
|
3
|
-
class AssemblyMusic
|
4
|
-
include Debug
|
5
|
-
|
6
|
-
def initialize(workspace_root)
|
7
|
-
# Generic
|
8
|
-
@workspace_root = workspace_root
|
9
|
-
|
10
|
-
# Music related
|
11
|
-
@resources = {}
|
12
|
-
|
13
|
-
#@channels = Array.new
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_context
|
18
|
-
self
|
19
|
-
end
|
20
|
-
|
21
|
-
def generate
|
22
|
-
# prepare music.s - music assembler file
|
23
|
-
File.write(
|
24
|
-
"#{@workspace_root}/tmp/burn/asset/music.s",
|
25
|
-
File.read("#{@workspace_root}/tmp/burn/asset/music.s")
|
26
|
-
.gsub(/__@__EXPORT__@__/, @resources.keys.map{|p| " .export _music_#{p}"}.join("\n"))
|
27
|
-
.gsub(/__@__INCLUDE__@__/, @resources.keys.map{|p| "_music_#{p}: .include \"mus_#{p}.s\""}.join("\n"))
|
28
|
-
)
|
29
|
-
|
30
|
-
# preparing each song file
|
31
|
-
@resources.each {|resource_name, channels|
|
32
|
-
# prepare other music resources
|
33
|
-
File.write( "#{@workspace_root}/tmp/burn/asset/mus_#{resource_name}.s",
|
34
|
-
File.read(File.dirname(__FILE__)+"/template/mus_template.s")
|
35
|
-
.gsub(/__@__NAME__@__/, resource_name)
|
36
|
-
.gsub(/__@__CHANNEL1__@__/, channels.shift || "")
|
37
|
-
.gsub(/__@__CHANNEL2__@__/, channels.shift || "")
|
38
|
-
.gsub(/__@__CHANNEL3__@__/, channels.shift || "")
|
39
|
-
.gsub(/__@__CHANNEL4__@__/, channels.shift || "")
|
40
|
-
.gsub(/__@__CHANNEL5__@__/, channels.shift || "")
|
41
|
-
)
|
42
|
-
}
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Burn
|
2
|
-
module Generator
|
3
|
-
class AssemblySoundEffect
|
4
|
-
include Debug
|
5
|
-
attr_reader :resources
|
6
|
-
|
7
|
-
def initialize(workspace_root)
|
8
|
-
# Generic
|
9
|
-
@workspace_root = workspace_root
|
10
|
-
|
11
|
-
# Music related
|
12
|
-
@resources = {}
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def get_context
|
17
|
-
self
|
18
|
-
end
|
19
|
-
|
20
|
-
def generate
|
21
|
-
# prepare sound.s - sound effect assembler file
|
22
|
-
File.write(
|
23
|
-
"#{@workspace_root}/tmp/burn/asset/sounds.s",
|
24
|
-
"sounds:\n" \
|
25
|
-
+ @resources.keys.map{|p| " .word @#{p}"}.join("\n") \
|
26
|
-
+ "\n" \
|
27
|
-
+ @resources.map{|key,value| "@#{key}:\n#{value.join} .byte $ff\n" }.join
|
28
|
-
)
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Burn
|
2
|
-
module Generator
|
3
|
-
class CSource
|
4
|
-
include Debug
|
5
|
-
attr_reader :global, :code_blocks
|
6
|
-
|
7
|
-
def initialize(workspace_root)
|
8
|
-
# Generic
|
9
|
-
@workspace_root = workspace_root
|
10
|
-
@global = Array.new
|
11
|
-
@code_blocks = Array.new
|
12
|
-
|
13
|
-
# Scene related
|
14
|
-
@pattern_tables = Array.new
|
15
|
-
@pattern_table_pointer = 80 #0x50 equivalent
|
16
|
-
@pattern_table_index = Hash.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_context
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def generate
|
24
|
-
# Initialization for codeblocks
|
25
|
-
@code_blocks.unshift "init();"
|
26
|
-
|
27
|
-
# generate source code
|
28
|
-
File.write(
|
29
|
-
"#{@workspace_root}/tmp/burn/main.c",
|
30
|
-
File.read(File.dirname(__FILE__) + "/template/template.c")
|
31
|
-
.gsub(/__@__MAIN__@__/, @code_blocks.join("\n"))
|
32
|
-
.gsub(/__@__GLOBAL__@__/, @global.join("\n"))
|
33
|
-
)
|
34
|
-
|
35
|
-
# save pattern tables associated with source code
|
36
|
-
pattern_header = []
|
37
|
-
File.open("#{@workspace_root}/tmp/burn/asset/tileset.chr", "rb") do |f|
|
38
|
-
pattern_header << f.read(16*80)
|
39
|
-
end
|
40
|
-
File.open("#{@workspace_root}/tmp/burn/asset/tileset.chr", "wb") do |f|
|
41
|
-
f << pattern_header[0]
|
42
|
-
@pattern_tables.each do |p|
|
43
|
-
f << p
|
44
|
-
end
|
45
|
-
(8192-16*80-@pattern_tables.count*16).times do |i|
|
46
|
-
f << ["0x00"].pack("B*")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/lib/burn/util/server.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Burn
|
2
|
-
module Util
|
3
|
-
class Server
|
4
|
-
require 'webrick'
|
5
|
-
|
6
|
-
def initialize(document_root)
|
7
|
-
@server = WEBrick::HTTPServer.new({:DocumentRoot => document_root, :BindAddress => '127.0.0.1', :Port => 17890})
|
8
|
-
trap 'INT' do
|
9
|
-
@server.shutdown
|
10
|
-
end
|
11
|
-
@server.mount_proc('/shutdown'){ |req, resp|
|
12
|
-
@server.stop
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def start
|
17
|
-
@server.start
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|