burn 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +621 -0
- data/README.md +467 -0
- data/Rakefile +1 -0
- data/bin/burn +14 -0
- data/lib/burn/builder.rb +65 -0
- data/lib/burn/cli.rb +187 -0
- data/lib/burn/debug.rb +25 -0
- data/lib/burn/dsl/channel_stream.rb +105 -0
- data/lib/burn/dsl/declare.rb +42 -0
- data/lib/burn/dsl/dsl_base.rb +31 -0
- data/lib/burn/dsl/music.rb +36 -0
- data/lib/burn/dsl/note.rb +125 -0
- data/lib/burn/dsl/scene.rb +278 -0
- data/lib/burn/dsl/sound.rb +30 -0
- data/lib/burn/dsl/sound_effect.rb +91 -0
- data/lib/burn/dsl.rb +8 -0
- data/lib/burn/generator/assembly_music.rb +47 -0
- data/lib/burn/generator/assembly_sound_effect.rb +33 -0
- data/lib/burn/generator/c_source.rb +54 -0
- data/lib/burn/generator/template/mus_template.s +49 -0
- data/lib/burn/generator/template/template.c +88 -0
- data/lib/burn/generator.rb +3 -0
- data/lib/burn/tools/mac/cc65/asminc/_file.inc +27 -0
- data/lib/burn/tools/mac/cc65/asminc/_heap.inc +35 -0
- data/lib/burn/tools/mac/cc65/asminc/apple2.inc +64 -0
- data/lib/burn/tools/mac/cc65/asminc/atari.inc +1175 -0
- data/lib/burn/tools/mac/cc65/asminc/atari.mac +59 -0
- data/lib/burn/tools/mac/cc65/asminc/atmos.inc +110 -0
- data/lib/burn/tools/mac/cc65/asminc/c128.inc +214 -0
- data/lib/burn/tools/mac/cc65/asminc/c16.inc +9 -0
- data/lib/burn/tools/mac/cc65/asminc/c64.inc +212 -0
- data/lib/burn/tools/mac/cc65/asminc/cbm.mac +50 -0
- data/lib/burn/tools/mac/cc65/asminc/cbm510.inc +182 -0
- data/lib/burn/tools/mac/cc65/asminc/cbm610.inc +110 -0
- data/lib/burn/tools/mac/cc65/asminc/cbm_filetype.inc +34 -0
- data/lib/burn/tools/mac/cc65/asminc/cpu.mac +24 -0
- data/lib/burn/tools/mac/cc65/asminc/ctype.inc +29 -0
- data/lib/burn/tools/mac/cc65/asminc/em-error.inc +49 -0
- data/lib/burn/tools/mac/cc65/asminc/em-kernel.inc +106 -0
- data/lib/burn/tools/mac/cc65/asminc/errno.inc +36 -0
- data/lib/burn/tools/mac/cc65/asminc/fcntl.inc +21 -0
- data/lib/burn/tools/mac/cc65/asminc/generic.mac +55 -0
- data/lib/burn/tools/mac/cc65/asminc/get_tv.inc +22 -0
- data/lib/burn/tools/mac/cc65/asminc/joy-error.inc +44 -0
- data/lib/burn/tools/mac/cc65/asminc/joy-kernel.inc +85 -0
- data/lib/burn/tools/mac/cc65/asminc/longbranch.mac +88 -0
- data/lib/burn/tools/mac/cc65/asminc/lynx.inc +279 -0
- data/lib/burn/tools/mac/cc65/asminc/modload.inc +78 -0
- data/lib/burn/tools/mac/cc65/asminc/mouse-kernel.inc +180 -0
- data/lib/burn/tools/mac/cc65/asminc/nes.inc +93 -0
- data/lib/burn/tools/mac/cc65/asminc/o65.inc +150 -0
- data/lib/burn/tools/mac/cc65/asminc/opcodes.inc +509 -0
- data/lib/burn/tools/mac/cc65/asminc/pet.inc +54 -0
- data/lib/burn/tools/mac/cc65/asminc/plus4.inc +86 -0
- data/lib/burn/tools/mac/cc65/asminc/ser-error.inc +54 -0
- data/lib/burn/tools/mac/cc65/asminc/ser-kernel.inc +162 -0
- data/lib/burn/tools/mac/cc65/asminc/signal.inc +57 -0
- data/lib/burn/tools/mac/cc65/asminc/smc.inc +245 -0
- data/lib/burn/tools/mac/cc65/asminc/stdio.inc +70 -0
- data/lib/burn/tools/mac/cc65/asminc/supervision.inc +76 -0
- data/lib/burn/tools/mac/cc65/asminc/tgi-error.inc +52 -0
- data/lib/burn/tools/mac/cc65/asminc/tgi-kernel.inc +234 -0
- data/lib/burn/tools/mac/cc65/asminc/tgi-vectorfont.inc +70 -0
- data/lib/burn/tools/mac/cc65/asminc/time.inc +59 -0
- data/lib/burn/tools/mac/cc65/asminc/utsname.inc +46 -0
- data/lib/burn/tools/mac/cc65/asminc/vic20.inc +75 -0
- data/lib/burn/tools/mac/cc65/asminc/zeropage.inc +26 -0
- data/lib/burn/tools/mac/cc65/bin/ca65 +0 -0
- data/lib/burn/tools/mac/cc65/bin/cc65 +0 -0
- data/lib/burn/tools/mac/cc65/bin/ld65 +0 -0
- data/lib/burn/tools/other/cc65/asminc/_file.inc +27 -0
- data/lib/burn/tools/other/cc65/asminc/_heap.inc +35 -0
- data/lib/burn/tools/other/cc65/asminc/apple2.inc +64 -0
- data/lib/burn/tools/other/cc65/asminc/atari.inc +1175 -0
- data/lib/burn/tools/other/cc65/asminc/atari.mac +59 -0
- data/lib/burn/tools/other/cc65/asminc/atmos.inc +110 -0
- data/lib/burn/tools/other/cc65/asminc/c128.inc +214 -0
- data/lib/burn/tools/other/cc65/asminc/c16.inc +9 -0
- data/lib/burn/tools/other/cc65/asminc/c64.inc +212 -0
- data/lib/burn/tools/other/cc65/asminc/cbm.mac +50 -0
- data/lib/burn/tools/other/cc65/asminc/cbm510.inc +182 -0
- data/lib/burn/tools/other/cc65/asminc/cbm610.inc +110 -0
- data/lib/burn/tools/other/cc65/asminc/cbm_filetype.inc +34 -0
- data/lib/burn/tools/other/cc65/asminc/cpu.mac +24 -0
- data/lib/burn/tools/other/cc65/asminc/ctype.inc +29 -0
- data/lib/burn/tools/other/cc65/asminc/em-error.inc +49 -0
- data/lib/burn/tools/other/cc65/asminc/em-kernel.inc +106 -0
- data/lib/burn/tools/other/cc65/asminc/errno.inc +36 -0
- data/lib/burn/tools/other/cc65/asminc/fcntl.inc +21 -0
- data/lib/burn/tools/other/cc65/asminc/generic.mac +55 -0
- data/lib/burn/tools/other/cc65/asminc/get_tv.inc +22 -0
- data/lib/burn/tools/other/cc65/asminc/joy-error.inc +44 -0
- data/lib/burn/tools/other/cc65/asminc/joy-kernel.inc +85 -0
- data/lib/burn/tools/other/cc65/asminc/longbranch.mac +88 -0
- data/lib/burn/tools/other/cc65/asminc/lynx.inc +279 -0
- data/lib/burn/tools/other/cc65/asminc/modload.inc +78 -0
- data/lib/burn/tools/other/cc65/asminc/mouse-kernel.inc +180 -0
- data/lib/burn/tools/other/cc65/asminc/nes.inc +93 -0
- data/lib/burn/tools/other/cc65/asminc/o65.inc +150 -0
- data/lib/burn/tools/other/cc65/asminc/opcodes.inc +509 -0
- data/lib/burn/tools/other/cc65/asminc/pet.inc +54 -0
- data/lib/burn/tools/other/cc65/asminc/plus4.inc +86 -0
- data/lib/burn/tools/other/cc65/asminc/ser-error.inc +54 -0
- data/lib/burn/tools/other/cc65/asminc/ser-kernel.inc +162 -0
- data/lib/burn/tools/other/cc65/asminc/signal.inc +57 -0
- data/lib/burn/tools/other/cc65/asminc/smc.inc +245 -0
- data/lib/burn/tools/other/cc65/asminc/stdio.inc +70 -0
- data/lib/burn/tools/other/cc65/asminc/supervision.inc +76 -0
- data/lib/burn/tools/other/cc65/asminc/tgi-error.inc +52 -0
- data/lib/burn/tools/other/cc65/asminc/tgi-kernel.inc +234 -0
- data/lib/burn/tools/other/cc65/asminc/tgi-vectorfont.inc +70 -0
- data/lib/burn/tools/other/cc65/asminc/time.inc +59 -0
- data/lib/burn/tools/other/cc65/asminc/utsname.inc +46 -0
- data/lib/burn/tools/other/cc65/asminc/vic20.inc +75 -0
- data/lib/burn/tools/other/cc65/asminc/zeropage.inc +26 -0
- data/lib/burn/tools/other/cc65/bin/ca65 +0 -0
- data/lib/burn/tools/other/cc65/bin/cc65 +0 -0
- data/lib/burn/tools/other/cc65/bin/ld65 +0 -0
- data/lib/burn/tools/win/cc65/asminc/_file.inc +27 -0
- data/lib/burn/tools/win/cc65/asminc/_heap.inc +35 -0
- data/lib/burn/tools/win/cc65/asminc/apple2.inc +64 -0
- data/lib/burn/tools/win/cc65/asminc/atari.inc +1101 -0
- data/lib/burn/tools/win/cc65/asminc/atmos.inc +31 -0
- data/lib/burn/tools/win/cc65/asminc/c128.inc +213 -0
- data/lib/burn/tools/win/cc65/asminc/c16.inc +9 -0
- data/lib/burn/tools/win/cc65/asminc/c64.inc +212 -0
- data/lib/burn/tools/win/cc65/asminc/cbm510.inc +182 -0
- data/lib/burn/tools/win/cc65/asminc/cbm610.inc +110 -0
- data/lib/burn/tools/win/cc65/asminc/ctype.inc +29 -0
- data/lib/burn/tools/win/cc65/asminc/em-error.inc +44 -0
- data/lib/burn/tools/win/cc65/asminc/em-kernel.inc +100 -0
- data/lib/burn/tools/win/cc65/asminc/errno.inc +36 -0
- data/lib/burn/tools/win/cc65/asminc/fcntl.inc +21 -0
- data/lib/burn/tools/win/cc65/asminc/get_tv.inc +22 -0
- data/lib/burn/tools/win/cc65/asminc/joy-error.inc +44 -0
- data/lib/burn/tools/win/cc65/asminc/joy-kernel.inc +85 -0
- data/lib/burn/tools/win/cc65/asminc/lynx.inc +273 -0
- data/lib/burn/tools/win/cc65/asminc/modload.inc +78 -0
- data/lib/burn/tools/win/cc65/asminc/mouse-kernel.inc +179 -0
- data/lib/burn/tools/win/cc65/asminc/nes.inc +93 -0
- data/lib/burn/tools/win/cc65/asminc/o65.inc +135 -0
- data/lib/burn/tools/win/cc65/asminc/pet.inc +45 -0
- data/lib/burn/tools/win/cc65/asminc/plus4.inc +87 -0
- data/lib/burn/tools/win/cc65/asminc/rs232.inc +19 -0
- data/lib/burn/tools/win/cc65/asminc/ser-error.inc +50 -0
- data/lib/burn/tools/win/cc65/asminc/ser-kernel.inc +161 -0
- data/lib/burn/tools/win/cc65/asminc/signal.inc +57 -0
- data/lib/burn/tools/win/cc65/asminc/stdio.inc +70 -0
- data/lib/burn/tools/win/cc65/asminc/supervision.inc +76 -0
- data/lib/burn/tools/win/cc65/asminc/tgi-error.inc +48 -0
- data/lib/burn/tools/win/cc65/asminc/tgi-kernel.inc +183 -0
- data/lib/burn/tools/win/cc65/asminc/tgi-mode.inc +48 -0
- data/lib/burn/tools/win/cc65/asminc/time.inc +59 -0
- data/lib/burn/tools/win/cc65/asminc/utsname.inc +46 -0
- data/lib/burn/tools/win/cc65/asminc/vic20.inc +77 -0
- data/lib/burn/tools/win/cc65/asminc/zeropage.inc +22 -0
- data/lib/burn/tools/win/cc65/bin/ca65.exe +0 -0
- data/lib/burn/tools/win/cc65/bin/cc65.exe +0 -0
- data/lib/burn/tools/win/cc65/bin/ld65.exe +0 -0
- data/lib/burn/util/os.rb +38 -0
- data/lib/burn/util/patternizer.rb +62 -0
- data/lib/burn/util/pxes.rb +180 -0
- data/lib/burn/util/server.rb +21 -0
- data/lib/burn/util.rb +4 -0
- data/lib/burn/version.rb +3 -0
- data/lib/burn/workspace_default/asset/crt0.s +260 -0
- data/lib/burn/workspace_default/asset/famitone.s +1031 -0
- data/lib/burn/workspace_default/asset/mus_instruments.s +50 -0
- data/lib/burn/workspace_default/asset/music.s +3 -0
- data/lib/burn/workspace_default/asset/nes.cfg +83 -0
- data/lib/burn/workspace_default/asset/neslib.h +213 -0
- data/lib/burn/workspace_default/asset/neslib.s +923 -0
- data/lib/burn/workspace_default/asset/runtime.lib +0 -0
- data/lib/burn/workspace_default/asset/sounds.s +143 -0
- data/lib/burn/workspace_default/asset/test.h +22 -0
- data/lib/burn/workspace_default/asset/tileset.chr +0 -0
- data/lib/burn/workspace_default/release/js/emulator.html +42 -0
- data/lib/burn/workspace_default/release/js/js/dynamicaudio-89ba58da476270a9b630.min.js +1 -0
- data/lib/burn/workspace_default/release/js/js/jquery-1.4.2.min.js +154 -0
- data/lib/burn/workspace_default/release/js/js/jsnes-4e7a7260aa.js +7149 -0
- data/lib/burn/workspace_default/release/js/swf/dynamicaudio.swf +0 -0
- data/lib/burn/workspace_default/scripts/compile.bat +30 -0
- data/lib/burn/workspace_default/scripts/compile.sh +30 -0
- data/lib/burn.rb +11 -0
- data/test/helper.rb +8 -0
- data/test/runner.rb +2 -0
- data/test/test_burn.rb +14 -0
- data/test/test_dsl.rb +22 -0
- data/test/test_pxes.rb +48 -0
- metadata +270 -0
data/lib/burn/cli.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
module Burn
|
2
|
+
class BurnTasks < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
super
|
7
|
+
@workspace_root = Dir.getwd
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.dirname(__FILE__) + "/.."
|
12
|
+
end
|
13
|
+
|
14
|
+
default_task :make
|
15
|
+
|
16
|
+
desc "make <filename>", "Compile and build application binary from Burn DSL file"
|
17
|
+
option :preview, :type => :boolean, :aliases => '-p', :desc => "Preview .out application right after compilation"
|
18
|
+
option :debug, :type => :string, :aliases => '-d', :desc => "Debug mode"
|
19
|
+
option :verbose, :type => :boolean, :desc => "Print logs as much as possible", :default => false
|
20
|
+
option :chrome, :type => :boolean, :aliases => '-c', :desc => "Run emulator on chrome instead of firefox", :default => false
|
21
|
+
def make(mainfile=nil)
|
22
|
+
mainfile="main.rb" if mainfile.nil?
|
23
|
+
|
24
|
+
if !File.exist?(mainfile) then
|
25
|
+
help
|
26
|
+
|
27
|
+
else
|
28
|
+
|
29
|
+
# used a icon from noun project. Thanks Jenny!
|
30
|
+
# http://thenounproject.com/term/fire/24187/
|
31
|
+
say <<-EOS
|
32
|
+
|
33
|
+
`.::-`
|
34
|
+
:hNMMNNds/.
|
35
|
+
:dMMMMMMNdo.
|
36
|
+
`oNMMMMMMMNh:
|
37
|
+
/NMMMMMMMMNy.
|
38
|
+
+MMMMMMMMMMm/
|
39
|
+
dMMMMMMMMMMNo
|
40
|
+
oMMMMMMMMMMMM+
|
41
|
+
+MMMMMMMMMMMMN/
|
42
|
+
sMMMMMMMMMMMMMm.
|
43
|
+
`mMMMMMMMMMMMMMMs ::`
|
44
|
+
/MMMMMMMMMMMMMMMN. `hh/`
|
45
|
+
`dMMMMMMMMMMMMMMMMo -NMd/`
|
46
|
+
sMMMMMMMMMMMMMMMMMd yMMMh-
|
47
|
+
/MMMMMMMMMMMMMMMMMMN. /MMMMN+
|
48
|
+
:NMMMMMMMMMMMMMMMMMMM- :MMMMMMo`
|
49
|
+
-mMMMMMMMMMMMMMMMMMMMM/ oMMMMMMMo
|
50
|
+
.dMMMMMMMMMMMMMMMMMMMMMo .mMMMMMMMN:
|
51
|
+
.dMMMMMMMMMMMMMMMMMMMMMMm` .dMMMMMMMMMm`
|
52
|
+
`dMMMMMMMMMMMMMMMMMMMMMMMMy.```/mMMMMMMMMMMMo
|
53
|
+
`hMMMMMMMMMMMMMMMNNNMMMMMMMMNhhmMMMMMMMMMMMMMm`
|
54
|
+
`hMMMMMMMMMMMMMMMN/`-/yNMMMMMMMMMMMMMMMMMMMMMMM:
|
55
|
+
`yMMMMMMMMMMMMMMMMMN- .hMMMMMMMMMMMMMMMMMMMMMMy
|
56
|
+
sMMMMMMMMMMMMMMMMMMMy sMMMMMMMMMMMMMMMMMMMMMd
|
57
|
+
+MMMMMMMMMMMMMMMMMMMMd `hMMMMMMMMMMMMMMMMMMMMN`
|
58
|
+
-NMMMMMMMMMMMMMMMMMMMMs .NMMMMMMMMMMMMMMMMMMMM-
|
59
|
+
`dMMMMMMMMMMMMMMMMMMMMm. sMMMMMMMMMMMMMMMMMMMM:
|
60
|
+
+MMMMMMMMMMMMMMMMMMMMN- -MMMMMMMMMMMMMMMMMMMM.
|
61
|
+
`mMMMMMMMMMMMMMMMMMMMm- NMMMN+NMMMMMMMMMMMMN
|
62
|
+
/MMMMMMMMMMMMMMMMMMMh. NMMMM--mMMMMMMMMMMMh
|
63
|
+
yMMMMMMMMMMMMMMMMMN+` .MMMMM+ -mMMMMMMMMMM+
|
64
|
+
`mMMMMMMMMMMMMMMMMh- +MMMMM: /MMMMMMMMMN.
|
65
|
+
-MMMMMMMMMMMMMMMN+` yMMMMs hMMMMMMMMy
|
66
|
+
:MMMMMMMMMMMMMMd- :hhy:` /MMMMMMMN.
|
67
|
+
.NMMMMMMMMMMMMy. `` -MMMMMMMo
|
68
|
+
dMMMMMMMMMMMs` .MMMMMMd`
|
69
|
+
+MMMMMMMMMMy` :MMMMMN-
|
70
|
+
`dMMMMMMMMN. sMMMMN/
|
71
|
+
:NMMMMMMMh `mMMMN+
|
72
|
+
+MMMMMMMs burn oMMMN+
|
73
|
+
+NMMMMMh -NMMm:
|
74
|
+
/mMMMMN- v#{VERSION} .dMNy.
|
75
|
+
.hNMMMh` .dNh:
|
76
|
+
`/mMMMh. -hy:`
|
77
|
+
`+mMMm/` `:+.
|
78
|
+
`/hNMd+. ``
|
79
|
+
.+hNNy/.
|
80
|
+
`-/oo:
|
81
|
+
|
82
|
+
|
83
|
+
EOS
|
84
|
+
# init
|
85
|
+
say "."
|
86
|
+
remove_dir "#{@workspace_root}/tmp/burn", :verbose => options[:verbose]
|
87
|
+
empty_directory "#{@workspace_root}/tmp/burn", :verbose => options[:verbose]
|
88
|
+
directory File.dirname(__FILE__) + "/workspace_default", "#{@workspace_root}/tmp/burn", :verbose => options[:verbose]
|
89
|
+
|
90
|
+
# compile and build .out
|
91
|
+
say ".."
|
92
|
+
builder = Builder.new(@workspace_root)
|
93
|
+
builder.verbose options[:verbose]
|
94
|
+
builder.load File.read("#{@workspace_root}/#{mainfile}")
|
95
|
+
builder.generate
|
96
|
+
|
97
|
+
# Prepare compilers
|
98
|
+
say "..."
|
99
|
+
env = Burn::Util::Os.new
|
100
|
+
directory File.dirname(__FILE__) + "/tools/#{env.os_name}", "#{@workspace_root}/tmp/burn", :verbose => options[:verbose]
|
101
|
+
|
102
|
+
# Finally compile
|
103
|
+
say "...."
|
104
|
+
redirect = ""
|
105
|
+
if env.is_win? then
|
106
|
+
command = ""
|
107
|
+
ext = "bat"
|
108
|
+
redirect = " > nul" if !options[:verbose]
|
109
|
+
|
110
|
+
else
|
111
|
+
command = "/bin/bash "
|
112
|
+
ext = "sh"
|
113
|
+
redirect = " > /dev/null" if !options[:verbose]
|
114
|
+
|
115
|
+
# Set permissions to execute compilers
|
116
|
+
Dir::glob("#{@workspace_root}/tmp/burn/cc65/bin/*65").each do |f|
|
117
|
+
File.chmod(0777, f)
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
run "#{command}#{@workspace_root}/tmp/burn/scripts/compile.#{ext} #{@workspace_root}/tmp/burn #{redirect}", :verbose => options[:verbose]
|
122
|
+
|
123
|
+
# prepare customized emulator
|
124
|
+
say "....."
|
125
|
+
require 'base64'
|
126
|
+
File.write(
|
127
|
+
"#{@workspace_root}/tmp/burn/release/js/emulator.html",
|
128
|
+
File.read(File.dirname(__FILE__)+"/workspace_default/release/js/emulator.html")
|
129
|
+
.gsub(/__@__TITLE__@__/, mainfile)
|
130
|
+
.gsub(/__@__ROMDATA__@__/,
|
131
|
+
Base64::strict_encode64(
|
132
|
+
File.binread("#{@workspace_root}/tmp/burn/main.out")
|
133
|
+
)
|
134
|
+
)
|
135
|
+
)
|
136
|
+
copy_file "#{@workspace_root}/tmp/burn/main.out", "#{@workspace_root}/tmp/burn/release/js/main.out", :verbose => options[:verbose]
|
137
|
+
|
138
|
+
say "Burned."
|
139
|
+
|
140
|
+
# run simulator
|
141
|
+
play if options[:preview]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "server <document_root>", "Run simple http server for emulator. This is mainly used by burn rubygem itself, not by user."
|
146
|
+
option :debug, :type => :string, :aliases => '-d', :desc => "Debug mode"
|
147
|
+
def server(document_root=nil)
|
148
|
+
raise Exception.new("document_root must be specified when you would like to run http server") if document_root.nil?
|
149
|
+
server = Burn::Util::Server.new(document_root)
|
150
|
+
server.start
|
151
|
+
end
|
152
|
+
|
153
|
+
desc "play <file>", "Invoke application simulator."
|
154
|
+
def play(mainfile=nil)
|
155
|
+
mainfile="main.out" if mainfile.nil?
|
156
|
+
env = Burn::Util::Os.new
|
157
|
+
|
158
|
+
# boot up webrick httpserver to download emulator script
|
159
|
+
command = "ruby " + File.dirname(__FILE__) + "/../../bin/burn server #{@workspace_root}/tmp/burn/release/js/ " + (options[:debug] ? "-d" : "")
|
160
|
+
if env.is_win? then
|
161
|
+
run "start #{command}", :verbose => options[:verbose]
|
162
|
+
else
|
163
|
+
run "#{command} &", :verbose => options[:verbose]
|
164
|
+
end
|
165
|
+
|
166
|
+
# open up browser
|
167
|
+
uri = "http://127.0.0.1:17890/emulator.html"
|
168
|
+
browser = options[:chrome] ? "chrome" : "firefox"
|
169
|
+
if env.is_win? then
|
170
|
+
run "start #{browser} #{uri}", :verbose => options[:verbose]
|
171
|
+
elsif env.is_mac? then
|
172
|
+
run "open -a #{browser} #{uri}", :verbose => options[:verbose]
|
173
|
+
else
|
174
|
+
run "/usr/bin/#{browser} #{uri}", :verbose => options[:verbose]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
desc "version", "Print version"
|
179
|
+
map %w(-v --version) => :version
|
180
|
+
def version
|
181
|
+
say "burn #{Burn::VERSION}"
|
182
|
+
end
|
183
|
+
|
184
|
+
# desc "release", "To be designed"
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
data/lib/burn/debug.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Burn
|
2
|
+
module Debug
|
3
|
+
class Logger
|
4
|
+
@@enabled = false
|
5
|
+
|
6
|
+
def enabled(flag)
|
7
|
+
@@enabled = flag
|
8
|
+
end
|
9
|
+
|
10
|
+
def enabled?
|
11
|
+
@@enabled
|
12
|
+
end
|
13
|
+
|
14
|
+
def log(message)
|
15
|
+
puts message if @@enabled
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def log(*messages)
|
20
|
+
messages.each do |message|
|
21
|
+
Debug::Logger.new.log message
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Burn
|
2
|
+
module Dsl
|
3
|
+
class ChannelStream
|
4
|
+
# tempo 193 ~ 211 (18 levels, 202 is median)
|
5
|
+
# see: http://ja.wikipedia.org/wiki/%E6%BC%94%E5%A5%8F%E8%A8%98%E5%8F%B7
|
6
|
+
TEMPO_BASE = 192
|
7
|
+
PRESTO = 1 + TEMPO_BASE
|
8
|
+
ALLEGRO = 2 + TEMPO_BASE
|
9
|
+
MODERATO = 3 + TEMPO_BASE
|
10
|
+
ANDANTE = 4 + TEMPO_BASE
|
11
|
+
ADAGIO = 5 + TEMPO_BASE
|
12
|
+
LARGO = 6 + TEMPO_BASE
|
13
|
+
|
14
|
+
# instrument number 64~126 (62steps) *note* no sound for 64, 65~72 seems working right now
|
15
|
+
BASS = 65
|
16
|
+
PIANO = 66
|
17
|
+
STRING = 67
|
18
|
+
ARPEGGIO = 68
|
19
|
+
STEP = 69
|
20
|
+
BELL = 70
|
21
|
+
ACOUSTIC = 71
|
22
|
+
GUITAR = 72
|
23
|
+
THEREMIN = 73
|
24
|
+
|
25
|
+
def initialize(index, instrument, tempo)
|
26
|
+
@index = index
|
27
|
+
|
28
|
+
@duration_list = [:half, :quarter, :eighth, :sixteenth]
|
29
|
+
@duration_numeric_list = {2=>:half, 4=>:quarter, 8=>:eighth, 16=>:sixteenth}
|
30
|
+
@duration_symbol_list = [:dotted, :triplet]
|
31
|
+
@articulation_list = [:tenuto, :staccato, :accent]
|
32
|
+
@instrument_list = [:piano, :bass]
|
33
|
+
|
34
|
+
@notes = Array.new
|
35
|
+
@notes << ChannelStream.const_get(tempo.upcase)
|
36
|
+
@notes << ChannelStream.const_get(instrument.upcase)
|
37
|
+
|
38
|
+
@default_duration = :quarter
|
39
|
+
@default_articulation = nil
|
40
|
+
@default_pitch = :c0
|
41
|
+
|
42
|
+
@output_buffer = Array.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def default(*args)
|
46
|
+
args.each{ |option|
|
47
|
+
if @duration_numeric_list.include?(option) then
|
48
|
+
@default_duration = @duration_numeric_list[option]
|
49
|
+
elsif @duration_list.include?(option) then
|
50
|
+
@default_duration = option
|
51
|
+
elsif @articulation_list.include?(option) then
|
52
|
+
@default_articulation = option
|
53
|
+
end
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def method_missing(method_symbol, *args, &block)
|
58
|
+
case method_symbol
|
59
|
+
when :segno then
|
60
|
+
@output_buffer << __translate
|
61
|
+
@output_buffer << "@chn#{@index.to_s}_segno:"
|
62
|
+
@notes = Array.new
|
63
|
+
when :dal_segno then
|
64
|
+
@output_buffer << __translate
|
65
|
+
@output_buffer << " .byte $fe" # end of stream
|
66
|
+
@output_buffer << " .word @chn#{@index.to_s}_segno"
|
67
|
+
@notes = Array.new
|
68
|
+
else
|
69
|
+
note = Note.new(@default_duration, method_symbol, @default_articulation)
|
70
|
+
args.each{ |option|
|
71
|
+
if @duration_numeric_list.include?(option) then
|
72
|
+
note.duration = @duration_numeric_list[option]
|
73
|
+
elsif @duration_list.include?(option) then
|
74
|
+
note.duration = option
|
75
|
+
elsif @articulation_list.include?(option) then
|
76
|
+
note.articulation = option
|
77
|
+
elsif @duration_symbol_list.include?(option) then
|
78
|
+
note.duration_symbol = option
|
79
|
+
end
|
80
|
+
}
|
81
|
+
@notes.concat note.generate
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def load(&block)
|
86
|
+
self.instance_eval &block
|
87
|
+
end
|
88
|
+
|
89
|
+
def generate
|
90
|
+
if @notes.count>0 then
|
91
|
+
@output_buffer << __translate
|
92
|
+
end
|
93
|
+
@output_buffer.join("\n")
|
94
|
+
# " .byte " + @notes.map{|p| "$%02x" % p}.join(",")
|
95
|
+
# " .byte $c1,$43,$1d,$80,$1f,$80,$21,$82,$1d,$80,$1d,$80,$1f,$92"
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
def __translate
|
100
|
+
" .byte " + @notes.map{|p| "$%02x" % p}.join(",")
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Burn
|
2
|
+
module Dsl
|
3
|
+
class Declare < DslBase
|
4
|
+
|
5
|
+
def initialize(resource_name, context)
|
6
|
+
super(resource_name, context)
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(method_symbol, *args, &block)
|
10
|
+
log :method_symbol=>method_symbol, :args=>args, block=>block
|
11
|
+
|
12
|
+
proc = Proc.new{|args|
|
13
|
+
key=args.shift
|
14
|
+
value=args.shift
|
15
|
+
if value.is_a?(String) then
|
16
|
+
patternizer = Burn::Util::Patternizer.new(value)
|
17
|
+
|
18
|
+
struct_var = "static sprite_schema #{key}={0, 0, {"
|
19
|
+
@pattern_table_index[key.to_sym] = @pattern_table_pointer
|
20
|
+
patternizer.patterns.each_with_index do |p, i|
|
21
|
+
log p, i, patternizer.height, "aaaaaaaaaaaaaaaaaaa"
|
22
|
+
struct_var += sprintf("%d, %d, %#x, 0,", (i % patternizer.width)*8 , (i / (patternizer.patterns.size / patternizer.height) )*8 , @pattern_table_pointer)
|
23
|
+
@pattern_tables << p
|
24
|
+
@pattern_table_pointer+=1
|
25
|
+
end
|
26
|
+
struct_var += "128}};"
|
27
|
+
|
28
|
+
@global.push sprintf(struct_var, "")
|
29
|
+
|
30
|
+
else
|
31
|
+
@global.push "static unsigned char #{key};"
|
32
|
+
@code_blocks.push "#{key}="+sprintf("%#x", value)+";"
|
33
|
+
log :key=>key, :value=>value.to_s(16), :value_class=>value.class
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
@context.instance_exec [method_symbol.to_s, args[0]], &proc
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Burn
|
2
|
+
module Dsl
|
3
|
+
class DslBase
|
4
|
+
# blankslate
|
5
|
+
instance_methods.each do |m|
|
6
|
+
undef_method m unless m.to_s =~ /object_id|__|method|instance_eval?/
|
7
|
+
end
|
8
|
+
|
9
|
+
include Debug
|
10
|
+
|
11
|
+
def initialize(resource_name, context)
|
12
|
+
@resource_name = resource_name
|
13
|
+
@context = context
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(method_symbol, *args, &block)
|
17
|
+
log :method_symbol=>method_symbol, :args=>args, :block=>block
|
18
|
+
raise Exception.new "Unknown DSL '#{method_symbol}' is used."
|
19
|
+
|
20
|
+
# # First argument will be block as always
|
21
|
+
# args.unshift block
|
22
|
+
# if @procs.key? method_symbol then
|
23
|
+
# @context.instance_exec args, &@procs[method_symbol]
|
24
|
+
# else
|
25
|
+
# raise Exception.new "Unknown DSL '#{method_symbol}' is used."
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Burn
|
2
|
+
module Dsl
|
3
|
+
class Music < DslBase
|
4
|
+
def initialize(resource_name, context)
|
5
|
+
super(resource_name, context)
|
6
|
+
|
7
|
+
@default_tempo = :allegro
|
8
|
+
|
9
|
+
if resource_name.nil? then
|
10
|
+
raise Exception.new "Resource name for Music class must be provided."
|
11
|
+
else
|
12
|
+
@resource_name = resource_name
|
13
|
+
end
|
14
|
+
|
15
|
+
@context.instance_exec resource_name, &lambda{|resource_name|
|
16
|
+
@resources["#{resource_name}"] = Array.new
|
17
|
+
}
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def channel(instrument, &block)
|
22
|
+
@context.instance_exec(@resource_name,@default_tempo) do |resource_name, default_tempo|
|
23
|
+
stream = ChannelStream.new(@resources["#{resource_name}"].count, instrument, default_tempo)
|
24
|
+
stream.load(&block)
|
25
|
+
@resources["#{resource_name}"] << stream.generate
|
26
|
+
#@resources["#{resource_name}"] << " .byte $43,$1d,$80,$1f,$80,$21,$82,$1d,$80,$1d,$80,$1f,$92"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def tempo(speed)
|
31
|
+
@default_tempo = speed
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Burn
|
2
|
+
module Dsl
|
3
|
+
class Note
|
4
|
+
# For music
|
5
|
+
# (0..59 are octaves 1-5, 63 note stop)
|
6
|
+
C = 0
|
7
|
+
D = 2
|
8
|
+
E = 4
|
9
|
+
F = 5
|
10
|
+
G = 7
|
11
|
+
A = 9
|
12
|
+
B = 11
|
13
|
+
|
14
|
+
CS = 11
|
15
|
+
DS = 1
|
16
|
+
ES = 3
|
17
|
+
FS = 4
|
18
|
+
GS = 6
|
19
|
+
AS = 8
|
20
|
+
BS = 10
|
21
|
+
|
22
|
+
REST = -1
|
23
|
+
|
24
|
+
|
25
|
+
# Empty Rows 128~191 (63steps)
|
26
|
+
DURATION_BASE = 127
|
27
|
+
SIXTEENTH = 4 + DURATION_BASE
|
28
|
+
EIGHTH = 10 + DURATION_BASE
|
29
|
+
QUARTER = 22 + DURATION_BASE
|
30
|
+
HALF = 46 + DURATION_BASE
|
31
|
+
DOTTED_SIXTEENTH = 7 + DURATION_BASE
|
32
|
+
DOTTED_EIGHTH = 16 + DURATION_BASE
|
33
|
+
DOTTED_QUARTER = 34 + DURATION_BASE
|
34
|
+
DOTTED_HALF = 70 + DURATION_BASE
|
35
|
+
TRIPLET_SIXTEENTH = 1 + DURATION_BASE
|
36
|
+
TRIPLET_EIGHTH = 4 + DURATION_BASE
|
37
|
+
TRIPLET_QUARTER = 10 + DURATION_BASE
|
38
|
+
TRIPLET_HALF = 22 + DURATION_BASE
|
39
|
+
|
40
|
+
TENUTO = 1.0
|
41
|
+
ACCENT = 0.7
|
42
|
+
STACCATO = 0.2
|
43
|
+
|
44
|
+
attr_accessor :duration, :articulation, :duration_symbol
|
45
|
+
|
46
|
+
def initialize(duration=:quarter, pitch=:c0, articulation=nil, duration_symbol=nil)
|
47
|
+
@pitch_list = {c:C, bsharp:C,
|
48
|
+
ds:DS, dflat:DS, csharp:DS,
|
49
|
+
d:D,
|
50
|
+
es:ES, eflat:ES, dsharp:DS,
|
51
|
+
e:E, fs:FS, fflat:FS,
|
52
|
+
f:F, esharp:F,
|
53
|
+
gs:GS, gflat:GS, fsharp:GS,
|
54
|
+
g:G,
|
55
|
+
as:AS, aflat:AS, gsharp:AS,
|
56
|
+
a:A,
|
57
|
+
bs:BS, bflat:BS, asharp:BS,
|
58
|
+
b:B, cs:CS, cflat:CS,
|
59
|
+
rest:REST,
|
60
|
+
}
|
61
|
+
|
62
|
+
# Fix pitch first at this early timing
|
63
|
+
if !pitch.to_s.match(/(.+)(\d)/).nil? then
|
64
|
+
raise Exception.new "pitch #{pitch.to_s} is not defined." if !@pitch_list.keys.include?(Regexp.last_match(1).to_sym)
|
65
|
+
@pitch = @pitch_list[Regexp.last_match(1).to_sym]
|
66
|
+
if Regexp.last_match(2).to_i <= 4 then
|
67
|
+
@octave = Regexp.last_match(2).to_i
|
68
|
+
else
|
69
|
+
raise Exception.new "Sorry only 0-4 octave range is supported."
|
70
|
+
end
|
71
|
+
else
|
72
|
+
raise Exception.new "pitch #{pitch.to_s} is not defined." if !@pitch_list.keys.include?(pitch)
|
73
|
+
@pitch = @pitch_list[pitch]
|
74
|
+
@octave = 0
|
75
|
+
end
|
76
|
+
|
77
|
+
@duration = duration
|
78
|
+
@articulation = articulation
|
79
|
+
@duration_symbol = duration_symbol
|
80
|
+
end
|
81
|
+
|
82
|
+
def generate
|
83
|
+
duration = get_actual_duration
|
84
|
+
|
85
|
+
result = Array.new
|
86
|
+
if @pitch==REST then
|
87
|
+
@articuulation = 0
|
88
|
+
else
|
89
|
+
result << @pitch + 12 * @octave
|
90
|
+
end
|
91
|
+
|
92
|
+
articulation = Note.const_get(@articulation.upcase) if !@articulation.nil?
|
93
|
+
if articulation.nil? then
|
94
|
+
result << duration
|
95
|
+
result << 63 # note stop
|
96
|
+
elsif articulation == TENUTO then
|
97
|
+
result << duration + 1
|
98
|
+
else
|
99
|
+
if (len(duration)*articulation).ceil > 0 then
|
100
|
+
result << DURATION_BASE + (len(duration)*articulation).ceil
|
101
|
+
result << 63 # note stop
|
102
|
+
end
|
103
|
+
if (len(duration)*(1.0 - articulation)).floor > 0 then
|
104
|
+
result << DURATION_BASE + (len(duration)*(1.0-articulation)).floor
|
105
|
+
end
|
106
|
+
end
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
def len(duration)
|
112
|
+
duration - DURATION_BASE
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_actual_duration
|
116
|
+
if !@duration_symbol.nil? then
|
117
|
+
Note.const_get(@duration_symbol.upcase.to_s + "_" + @duration.upcase.to_s)
|
118
|
+
else
|
119
|
+
Note.const_get(@duration.upcase.to_s)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|