burn 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/README.md
CHANGED
@@ -1,41 +1,10 @@
|
|
1
|
-
# Burn - a handy toolkit to
|
1
|
+
# Burn - a handy toolkit to homebrew 8-bit flavored applications from Ruby DSLs
|
2
2
|
|
3
|
-
|
3
|
+
A .nes application below is compiled in less than 500 lines of Ruby DSL code, including graphic and sound resources.([code](https://github.com/remore/burn/blob/master/example/rubima_wars/main.rb) / [online demo](http://k.swd.cc/burn/resource/example/rubima-wars/emulator.html))
|
4
4
|
|
5
|
-
|
6
|
-
scene do
|
7
|
-
label "Hello, World!"
|
8
|
-
end
|
9
|
-
```
|
10
|
-
|
11
|
-
Just like Recipe and Cookbook are DSL for Chef rubygem, this dead simple DSL is for Burn rubygem, and we call it Fuel. Burning this Fuel will produce [this](http://k.swd.cc/burn/resource/example/hello-world/emulator.html).
|
12
|
-
|
13
|
-
![Hello-world pic](http://k.swd.cc/burn/resource/screenshot/hello-world.png)
|
5
|
+
![rubima wars pic](http://k.swd.cc/burn/resource/screenshot/rubima-wars.png)
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
scene do
|
19
|
-
label "Hello, World!"
|
20
|
-
play "openning"
|
21
|
-
end
|
22
|
-
|
23
|
-
music "openning" do
|
24
|
-
tempo :allegro
|
25
|
-
channel "piano" do
|
26
|
-
segno
|
27
|
-
g :dotted
|
28
|
-
g :eighth, :staccato
|
29
|
-
a :dotted
|
30
|
-
a :eighth, :staccato
|
31
|
-
dal_segno
|
32
|
-
end
|
33
|
-
end
|
34
|
-
```
|
35
|
-
|
36
|
-
Check [the output](http://k.swd.cc/burn/resource/example/hello-world-with-music/emulator.html) from this.
|
37
|
-
|
38
|
-
Would you like to design retro 8-bit graphics? Here you go.
|
7
|
+
Next example is about cross-compilation. Assuming you write this simple Ruby DSL:
|
39
8
|
|
40
9
|
```ruby
|
41
10
|
declare do
|
@@ -66,596 +35,112 @@ scene do
|
|
66
35
|
sprite "star"
|
67
36
|
EOH
|
68
37
|
end
|
69
|
-
|
70
38
|
```
|
71
39
|
|
40
|
+
With Burn, you can compile this to .nes:
|
41
|
+
|
72
42
|
![star animated gif](http://k.swd.cc/burn/resource/screenshot/star.gif)
|
73
43
|
|
74
|
-
|
44
|
+
and at the same time, you can run this as a telnet server application:
|
45
|
+
|
46
|
+
![star animated telnet server app](http://k.swd.cc/burn/resource/screenshot/star-telnet.gif)
|
47
|
+
|
48
|
+
Just like Recipe and Cookbook are DSLs for the Chef rubygem, this dead simple DSL is for the Burn rubygem, and we call it Fuel.
|
49
|
+
|
50
|
+
Imagine 8-bit application like [ascii starwars movie](http://lifehacker.com/373571/watch-star-wars-in-text-via-telnet) can be created in seconds, seriously. Now is the time to go back and start to develop primitive, low-end application.
|
75
51
|
|
76
52
|
## Table Of Contents
|
77
53
|
|
78
54
|
* [Introduction](#introduction)
|
79
|
-
* [
|
55
|
+
* [Why Burn](#why-burn)
|
80
56
|
* [How It Works](#how-it-works)
|
57
|
+
* [Requirements](#requirements)
|
81
58
|
* [Getting Started](#getting-started)
|
82
59
|
* [Installation](#installation)
|
83
60
|
* [Quick Start](#quick-start)
|
84
|
-
|
85
|
-
* [Fuel DSL Methods](#fuel-dsl-methods)
|
86
|
-
* [Scene](#scene)
|
87
|
-
* [Declare](#declare)
|
88
|
-
* [Music](#music)
|
89
|
-
* [Sound](#sound)
|
90
|
-
* [Burning Fuel DSL In Action](#burning-fuel-dsl-in-action)
|
91
|
-
* [Programming With .rrb(Restricted Ruby) Syntax](#programming-with-rrbrestricted-ruby-syntax)
|
61
|
+
* [Fuel DSL](#fuel-dsl-methods)
|
92
62
|
* [Notes](#notes)
|
93
|
-
* [Personal Motivation](#personal-motivation)
|
94
63
|
* [Helpful Folks](#helpful-folks)
|
95
64
|
* [License](#license)
|
96
65
|
* [ToDos](#todos)
|
97
66
|
|
98
67
|
## Introduction
|
99
68
|
|
100
|
-
### Less Is More
|
101
|
-
|
102
|
-
Creating 8-bit flavored application mean neither outdated nor cheap, but good fit to rapid prototyping. It could be one of best options for education purpose as well.
|
103
|
-
|
104
|
-
Moreover, the executables built with burn will work at [almost any OS](http://en.wikipedia.org/wiki/List_of_video_game_emulators#Consoles). That said, consequently, burn is a multi-platform programming environment.
|
105
|
-
|
106
69
|
### How It Works
|
107
70
|
|
108
|
-
|
71
|
+
Burn have two modes, `:rom` mode nad `:telnet` mode.
|
72
|
+
|
73
|
+
For `:rom` mode, Burn uses cc65 executables embedded in its gemfile for compilation. The main workflow is as follows.
|
109
74
|
|
110
75
|
- translate ruby DSL file into c source code
|
111
76
|
- compile them to make executable(*.nes) by calling cc65
|
112
|
-
- provide emulator(JSNES) for
|
77
|
+
- provide an emulator(JSNES) for rapid application development
|
78
|
+
|
79
|
+
Meanwhile, for `:telnet` mode Burn works like this:
|
80
|
+
|
81
|
+
- translate ruby DSL file into CRuby source code
|
82
|
+
- provide telnet server function to run the code on burn VM
|
113
83
|
|
114
84
|
### Requirements
|
115
85
|
|
116
86
|
- Ruby1.9.1+
|
117
|
-
- gcc(
|
87
|
+
- gcc (Winows users do not require this)
|
88
|
+
|
89
|
+
Burn supports all major OS like MacOS, Unix-like systems and Windows.
|
118
90
|
|
119
91
|
## Getting Started
|
120
92
|
|
121
93
|
### Installation
|
122
94
|
|
123
95
|
sudo gem install burn
|
124
|
-
sudo burn init
|
96
|
+
sudo burn init
|
125
97
|
|
126
98
|
### Quick Start
|
127
99
|
|
128
|
-
|
129
|
-
|
100
|
+
# :nes mode
|
130
101
|
echo "scene {label 'hello world'}" > main.rb
|
131
|
-
burn
|
102
|
+
burn # make .nes rom and launch .nes emulator
|
132
103
|
ls tmp/burn/ | grep main.nes
|
104
|
+
|
105
|
+
# :telnet mode
|
106
|
+
echo -e "config(:app){ target :telnet }\nscene {label 'hello world'}" > main.rb
|
107
|
+
burn & # run telnet server
|
108
|
+
telnet localhost 60000
|
133
109
|
|
134
|
-
|
135
|
-
|
136
|
-
Customize example/shooting/main.rb and play with it if you please.
|
137
|
-
|
138
|
-
git clone https://github.com/remore/burn.git
|
139
|
-
cd burn/example/shooting
|
140
|
-
burn -p -c
|
141
|
-
|
142
|
-
# if you'd like to make executable, simply remove -p option or type burn make
|
143
|
-
burn
|
144
|
-
burn make
|
145
|
-
|
146
|
-
# you can boot the emulator up whenever you want(without burning Fuel DSL)
|
147
|
-
burn play
|
110
|
+
More Examples are available at example folder. kindly try to `git clone https://github.com/remore/burn.git` and play.
|
148
111
|
|
149
112
|
## Fuel DSL
|
150
113
|
|
151
|
-
Currently
|
152
|
-
|
153
|
-
* [Scene](#scene)
|
154
|
-
* [Sound](#sound)
|
155
|
-
* [Music](#music)
|
156
|
-
* [Declare](#declare)
|
157
|
-
|
158
|
-
### Scene
|
114
|
+
Currently example code are definitely the best reference. As to documentation, please see following materials:
|
159
115
|
|
160
|
-
|
116
|
+
[Reference for :nes mode](https://github.com/remore/burn/blob/master/FUEL-ROM.md)
|
161
117
|
|
162
|
-
|
118
|
+
Reference for :nes mode(coming soon)
|
163
119
|
|
164
|
-
|
120
|
+
...and there is many TBDs(articles about #show, #sprite, #rand and #is_pressed are coming very soon)
|
165
121
|
|
166
|
-
|
167
|
-
<dt>string String</dt>
|
168
|
-
<dd>Static string to display.</dd>
|
169
|
-
<dt>x Number</dt>
|
170
|
-
<dd>The horizontal coordinate to display, between 0 and 31.</dd>
|
171
|
-
<dt>y Number</dt>
|
172
|
-
<dd>The vertical coordinate to display, between 0 and 28.</dd>
|
173
|
-
</dl>
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
scene do
|
177
|
-
label "Hello, World!"
|
178
|
-
label "Hello, World!", 4, 5
|
179
|
-
end
|
180
|
-
```
|
181
|
-
|
182
|
-
![label pic](http://k.swd.cc/burn/resource/screenshot/label.png)
|
183
|
-
|
184
|
-
#### fade_in, fade_out
|
185
|
-
|
186
|
-
These methods can be used in a scene to fade in or out.
|
187
|
-
|
188
|
-
```ruby
|
189
|
-
scene do
|
190
|
-
label "Hello"
|
191
|
-
fade_in
|
192
|
-
main_loop
|
193
|
-
fade_out
|
194
|
-
goto "next"
|
195
|
-
end
|
196
|
-
```
|
197
|
-
|
198
|
-
#### play(song_title)
|
199
|
-
|
200
|
-
The play method can be used in a scene to play music.
|
201
|
-
|
202
|
-
<dl>
|
203
|
-
<dt>song_title String</dt>
|
204
|
-
<dd>Song title to play.</dd>
|
205
|
-
</dl>
|
206
|
-
|
207
|
-
```ruby
|
208
|
-
scene do
|
209
|
-
play "battle"
|
210
|
-
stop
|
211
|
-
end
|
212
|
-
|
213
|
-
music "battle" do
|
214
|
-
channel "string" do
|
215
|
-
g :dotted
|
216
|
-
g :eighth
|
217
|
-
c :half
|
218
|
-
end
|
219
|
-
end
|
220
|
-
```
|
221
|
-
|
222
|
-
#### stop
|
223
|
-
|
224
|
-
The stop method can be used in a scene to stop music.
|
225
|
-
|
226
|
-
```ruby
|
227
|
-
scene do
|
228
|
-
stop "battle"
|
229
|
-
end
|
230
|
-
```
|
231
|
-
|
232
|
-
#### color(palette, color, lightness=:lighter)
|
233
|
-
|
234
|
-
The color method can be used in a scene to pick a color and set it to specific palette.
|
235
|
-
|
236
|
-
<dl>
|
237
|
-
<dt>palette Symbol</dt>
|
238
|
-
<dd>Palette to set.
|
239
|
-
<table>
|
240
|
-
<tr>
|
241
|
-
<th>Palette Symbol</th>
|
242
|
-
<th>Description</th>
|
243
|
-
</tr>
|
244
|
-
<tr>
|
245
|
-
<td>:bg</td>
|
246
|
-
<td>Background color</td>
|
247
|
-
</tr>
|
248
|
-
<tr>
|
249
|
-
<td>:text</td>
|
250
|
-
<td>Foreground color</td>
|
251
|
-
</tr>
|
252
|
-
<tr>
|
253
|
-
<td>:palette_x1, :palette_x2, :palette_x3</td>
|
254
|
-
<td>Colors for :palette_x</td>
|
255
|
-
</tr>
|
256
|
-
<tr>
|
257
|
-
<td>:palette_y1, :palette_y2, :palette_y3</td>
|
258
|
-
<td>Colors for :palette_y</td>
|
259
|
-
</tr>
|
260
|
-
<tr>
|
261
|
-
<td>:palette_z1, :palette_z2, :palette_z3</td>
|
262
|
-
<td>Colors for :palette_z</td>
|
263
|
-
</tr>
|
264
|
-
<tr>
|
265
|
-
<td>:sprite</td>
|
266
|
-
<td>Sprite color</td>
|
267
|
-
</tr>
|
268
|
-
</table>
|
269
|
-
</dd>
|
270
|
-
<dt>color Symbol</dt>
|
271
|
-
<dd>Color to set. Available color pattern is shown below.<br />
|
272
|
-
<img src="http://www.thealmightyguru.com/Games/Hacking/Wiki/images/e/e8/Palette_NTSC.png">
|
273
|
-
<table>
|
274
|
-
<tr>
|
275
|
-
<th>Color Symbol</th>
|
276
|
-
</tr>
|
277
|
-
<tr><td>:white</td></tr>
|
278
|
-
<tr><td>:lightblue</td></tr>
|
279
|
-
<tr><td>:blue</td></tr>
|
280
|
-
<tr><td>:purple</td></tr>
|
281
|
-
<tr><td>:pink</td></tr>
|
282
|
-
<tr><td>:red</td></tr>
|
283
|
-
<tr><td>:deepred</td></tr>
|
284
|
-
<tr><td>:orange</td></tr>
|
285
|
-
<tr><td>:lightorange</td></tr>
|
286
|
-
<tr><td>:darkgreen</td></tr>
|
287
|
-
<tr><td>:green</td></tr>
|
288
|
-
<tr><td>:lightgreen</td></tr>
|
289
|
-
<tr><td>:bluegreen</td></tr>
|
290
|
-
<tr><td>:gray</td></tr>
|
291
|
-
<tr><td>:black</td></tr>
|
292
|
-
</table>
|
293
|
-
</dd>
|
294
|
-
<dt>lightness Symbol</dt>
|
295
|
-
<dd>Lightness of the color to set. `:darkest`, `:darker`, `:lighter` and `:lightest` can be set.</dd>
|
296
|
-
</dl>
|
297
|
-
|
298
|
-
```ruby
|
299
|
-
scene do
|
300
|
-
label "Hello, World!"
|
301
|
-
color :text, :green, :lighter
|
302
|
-
end
|
303
|
-
```
|
304
|
-
|
305
|
-
![color pic](http://k.swd.cc/burn/resource/screenshot/color.png)
|
306
|
-
|
307
|
-
#### wait(interval)
|
308
|
-
|
309
|
-
The wait method can be used in a scene to pause for certain period of time.
|
310
|
-
|
311
|
-
<dl>
|
312
|
-
<dt>interval Fixnum</dt>
|
313
|
-
<dd>Period of time to pause.</dd>
|
314
|
-
</dl>
|
315
|
-
|
316
|
-
|
317
|
-
```ruby
|
318
|
-
scene do
|
319
|
-
label "foobar"
|
320
|
-
fade_out
|
321
|
-
wait 100
|
322
|
-
goto "somewhere"
|
323
|
-
end
|
324
|
-
```
|
325
|
-
|
326
|
-
#### goto(scene_name)
|
327
|
-
|
328
|
-
The goto method can be used in a scene to jump the scene specified.
|
329
|
-
|
330
|
-
<dl>
|
331
|
-
<dt>scene_name String</dt>
|
332
|
-
<dd>Destination to jump.</dd>
|
333
|
-
</dl>
|
334
|
-
|
335
|
-
```ruby
|
336
|
-
scene "first" do
|
337
|
-
label "good morning"
|
338
|
-
goto "second"
|
339
|
-
end
|
340
|
-
|
341
|
-
scene "second" do
|
342
|
-
label "hi there"
|
343
|
-
end
|
344
|
-
```
|
345
|
-
|
346
|
-
#### inline(code)
|
347
|
-
|
348
|
-
The inline method can be used in a scene to inject c source code manually to compile with cc65. Should be used for debugging purpose.
|
349
|
-
|
350
|
-
<dl>
|
351
|
-
<dt>code String</dt>
|
352
|
-
<dd>C code to inject.</dd>
|
353
|
-
</dl>
|
354
|
-
|
355
|
-
```ruby
|
356
|
-
scene do
|
357
|
-
inline "x=1+2;"
|
358
|
-
end
|
359
|
-
```
|
360
|
-
|
361
|
-
#### screen(map, vars)
|
362
|
-
|
363
|
-
The screen method can be used to inflate map data to a scene.
|
364
|
-
|
365
|
-
<dl>
|
366
|
-
<dt>map String</dt>
|
367
|
-
<dd>Map data consists of hash keys of pattern design.</dd>
|
368
|
-
<dt>vars Hash</dt>
|
369
|
-
<dd>A list of pattern designs.</dd>
|
370
|
-
</dl>
|
371
|
-
|
372
|
-
```ruby
|
373
|
-
scene do
|
374
|
-
screen <<-EOH, { A:"tile", B:"wave", C:"mountain"}
|
375
|
-
|
376
|
-
AAAA AA AAA AAA AA A
|
377
|
-
AA A AA AA AA AA AA AA A
|
378
|
-
AA A AA AA AA AA AAA
|
379
|
-
AAAAA AA AA AA AA AA
|
380
|
-
AA A AA AAAAAAA AA AAA
|
381
|
-
AA A AA AA AA AA AA AA A
|
382
|
-
AAAA AAAA AA AA AAA AA A
|
383
|
-
|
384
|
-
BB BB BB BBB BBBBB
|
385
|
-
BB BB BB BB BB BB BB
|
386
|
-
BB BB BB BB BB BB BB BB
|
387
|
-
BB BB BB BB BBBBBBB BBBB
|
388
|
-
BB BB BB BB BB BB
|
389
|
-
BB BB BB BB BB BB
|
390
|
-
EOH
|
391
|
-
end
|
392
|
-
```
|
393
|
-
|
394
|
-
#### sound(effect_name)
|
395
|
-
|
396
|
-
The sound method in a scene can be used to play sound effect.
|
397
|
-
|
398
|
-
<dl>
|
399
|
-
<dt>effect_name String</dt>
|
400
|
-
<dd>Name of sound effect to play.</dd>
|
401
|
-
</dl>
|
402
|
-
|
403
|
-
```ruby
|
404
|
-
scene do
|
405
|
-
sound "dead"
|
406
|
-
end
|
407
|
-
|
408
|
-
sound "dead" do
|
409
|
-
effect do
|
410
|
-
velocity 15
|
411
|
-
length 5
|
412
|
-
pitch 200
|
413
|
-
end
|
414
|
-
end
|
415
|
-
```
|
416
|
-
|
417
|
-
#### paint(dest, palette)
|
418
|
-
|
419
|
-
The paint method in a scene can be used to associate color palette with pattern designs inflated on the screen. Typically #paint is called along with #color and #screen method.
|
420
|
-
|
421
|
-
<dl>
|
422
|
-
<dt>dest Range</dt>
|
423
|
-
<dd>Return value of #range(x_from, y_from, x_to, y_to) is expected. x_from and x_to takes the number between 0 and 255 while y_from and y_to takes the value between 0 and 239.</dd>
|
424
|
-
<dt>palette Symbol</dt>
|
425
|
-
<dd>Palette symbol to apply. Kindly refer candidate symbols listed at <a href="#colorpalette-color-lightnesslighter">color</a> section.</dd>
|
426
|
-
</dl>
|
427
|
-
|
428
|
-
```ruby
|
429
|
-
scene "title" do
|
430
|
-
color :palette_x1, :deepred, :darker
|
431
|
-
paint range("44px", "5px", "120px", "3px"), :palette_x # range takes String parameter
|
432
|
-
|
433
|
-
color :palette_y2, :pink, :darkest
|
434
|
-
paint range(30, 2, 30, 12), :palette_y # range method can take Number as well. In this case x_from and x_to takes the value between 0 and 31, while y_from and y_to takes the value from 0 and 29.
|
435
|
-
end
|
436
|
-
```
|
437
|
-
|
438
|
-
#### main_loop(rrb_source=nil)
|
439
|
-
|
440
|
-
The main_loop method in a scene can be used to repeat a block of code. More detail can be found at [.rrb section](#programming-with-rrbrestricted-ruby-syntax).
|
441
|
-
|
442
|
-
<dl>
|
443
|
-
<dt>rrb_source String</dt>
|
444
|
-
<dd>Source code written in .rrb(Resticted Ruby) syntax.</dd>
|
445
|
-
</dl>
|
446
|
-
|
447
|
-
```ruby
|
448
|
-
scene "title" do
|
449
|
-
color :palette_x1, :deepred, :darker
|
450
|
-
paint range("44px", "5px", "120px", "3px"), :palette_x # range takes String parameter
|
451
|
-
|
452
|
-
color :palette_y2, :pink, :darkest
|
453
|
-
paint range(30, 2, 30, 12), :palette_y # range method can take Number as well. In this case x_from and x_to takes the value between 0 and 31, while y_from and y_to takes the value from 0 and 29.
|
454
|
-
end
|
455
|
-
```
|
456
|
-
|
457
|
-
### Declare
|
458
|
-
|
459
|
-
Declare resource is essential part of programming with using Scene#main_loop.
|
460
|
-
|
461
|
-
If you give Number as shown below, then method name like #frame or #color_flag becomes variable in Scene#main_loop process.
|
462
|
-
|
463
|
-
```ruby
|
464
|
-
declare do
|
465
|
-
frame 0
|
466
|
-
color_flag 0
|
467
|
-
end
|
468
|
-
```
|
469
|
-
|
470
|
-
If you give String conststs of 8x8 character block just like following example code, then left left-hand member becomes sprite object in Scene#main_loop process.
|
471
|
-
|
472
|
-
```ruby
|
473
|
-
declare do
|
474
|
-
tile <<-EOH
|
475
|
-
11111111
|
476
|
-
11222211
|
477
|
-
11233211
|
478
|
-
11233211
|
479
|
-
11233211
|
480
|
-
11233211
|
481
|
-
11222211
|
482
|
-
11111111
|
483
|
-
EOH
|
484
|
-
end
|
485
|
-
```
|
486
|
-
|
487
|
-
### Music
|
488
|
-
|
489
|
-
This is where burn rubygem compose music for you. The only requirement for you to start to compose music is your favorite text editor.
|
490
|
-
|
491
|
-
Music resource can accept only two methods so far, #tempo and #channel.
|
492
|
-
|
493
|
-
#### tempo(speed)
|
494
|
-
|
495
|
-
The tempo method in a music can be used to set a tempo of a song.
|
496
|
-
|
497
|
-
<dl>
|
498
|
-
<dt>speed Symbol</dt>
|
499
|
-
<dd>song speed symbol to set.
|
500
|
-
<table>
|
501
|
-
<tr>
|
502
|
-
<th>Song Speed</th>
|
503
|
-
</tr>
|
504
|
-
<tr><td>:presto</td></tr>
|
505
|
-
<tr><td>:allegro</td></tr>
|
506
|
-
<tr><td>:moderato</td></tr>
|
507
|
-
<tr><td>:andante</td></tr>
|
508
|
-
<tr><td>:adagio</td></tr>
|
509
|
-
<tr><td>:largo</td></tr>
|
510
|
-
</table>
|
511
|
-
</dd>
|
512
|
-
</dl>
|
513
|
-
|
514
|
-
```ruby
|
515
|
-
music "fanfare" do
|
516
|
-
tempo :allegro
|
517
|
-
channel ...
|
518
|
-
end
|
519
|
-
```
|
520
|
-
|
521
|
-
#### channel(instrument)
|
522
|
-
|
523
|
-
The channel method in a music can be used to set a channel of the song. Maximum three channels per music can be set.
|
524
|
-
|
525
|
-
<dl>
|
526
|
-
<dt>instrument String</dt>
|
527
|
-
<dd>instrument to play.
|
528
|
-
<table>
|
529
|
-
<tr>
|
530
|
-
<th>Instrument</th>
|
531
|
-
</tr>
|
532
|
-
<tr><td>"bass"</td></tr>
|
533
|
-
<tr><td>"piano"</td></tr>
|
534
|
-
<tr><td>"string"</td></tr>
|
535
|
-
<tr><td>"arpeggio"</td></tr>
|
536
|
-
<tr><td>"step"</td></tr>
|
537
|
-
<tr><td>"bell"</td></tr>
|
538
|
-
<tr><td>"acoustic"</td></tr>
|
539
|
-
<tr><td>"guitar"</td></tr>
|
540
|
-
<tr><td>"theremin"</td></tr>
|
541
|
-
</table>
|
542
|
-
</dd>
|
543
|
-
</dl>
|
544
|
-
|
545
|
-
Notes of the music are described as shown below.
|
546
|
-
|
547
|
-
- Total 61 notes(5 octaves + rest) notes are available.
|
548
|
-
- For instance, available methods are, `#c0`(0 stands for octave), `#ds0`(s stands for flat), `#d0`, `#es0`...
|
549
|
-
- `#segno` and `#dal_segno` are available too
|
550
|
-
- This way you can repeat song
|
551
|
-
- Each note can take length as their parameter. Here is list of length available
|
552
|
-
- `:sixteenth`, `:eighth`, `:quarter`, `:half`
|
553
|
-
- `:dotted_sixteenth`, `:dotted_eighth`, `:dotted_quarter`, `:dotted_half`
|
554
|
-
- `:triplet_sixteenth`, `:triplet_eighth`, `:triplet_quarter`, `:triplet_half`
|
555
|
-
- Each note can take expression parameter as well
|
556
|
-
- `:tenuto`
|
557
|
-
- `:accent`
|
558
|
-
- `:staccato`
|
559
|
-
|
560
|
-
With these basic understanding how you can compose song, here is an example of music.
|
122
|
+
## Notes
|
561
123
|
|
562
|
-
|
563
|
-
music "sarabande" do
|
564
|
-
tempo :allegro
|
565
|
-
channel "string" do
|
566
|
-
segno
|
567
|
-
d2 :eighth
|
568
|
-
rest :eighth
|
569
|
-
e2 :eighth
|
570
|
-
rest :eighth
|
571
|
-
dal_segno
|
572
|
-
end
|
573
|
-
channel "piano" do
|
574
|
-
segno
|
575
|
-
a3 :dotted_eighth
|
576
|
-
rest :sixteenth
|
577
|
-
g3 :triplet_eighth
|
578
|
-
g3 :triplet_eighth
|
579
|
-
g3 :triplet_eighth
|
580
|
-
dal_segno
|
581
|
-
end
|
582
|
-
end
|
583
|
-
```
|
124
|
+
### Why Burn
|
584
125
|
|
585
|
-
|
586
|
-
|
587
|
-
Sound resource can accept only #effect method as of now. Available methods for #effect are shown below.
|
588
|
-
|
589
|
-
#### effect
|
590
|
-
|
591
|
-
with this block, you can call following method to configure sound setting.
|
592
|
-
|
593
|
-
####
|
594
|
-
|
595
|
-
The duty_cycle method in a sound can be used to set duty cycle type.
|
596
|
-
|
597
|
-
<dl>
|
598
|
-
<dt>duty_cycle(ratio)</dt>
|
599
|
-
<dd>duty cycle symbol to set. It takes :higher by default.
|
600
|
-
<table>
|
601
|
-
<tr>
|
602
|
-
<th>Duty Cycle Type</th>
|
603
|
-
<th>Value</th>
|
604
|
-
</tr>
|
605
|
-
<tr>
|
606
|
-
<td>:lowest</td>
|
607
|
-
<td>12.5%</td>
|
608
|
-
</tr>
|
609
|
-
<tr>
|
610
|
-
<td>:lower</td>
|
611
|
-
<td>25%</td>
|
612
|
-
</tr>
|
613
|
-
<tr>
|
614
|
-
<td>:higher</td>
|
615
|
-
<td>50%</td>
|
616
|
-
</tr>
|
617
|
-
<tr>
|
618
|
-
<td>:highest</td>
|
619
|
-
<td>75%</td>
|
620
|
-
</tr>
|
621
|
-
</table>
|
622
|
-
</dd>
|
623
|
-
<dt>velocity(level)</dt>
|
624
|
-
<dd>Volume level number of the sound, between 0 and 15. It takes 7 by default.</dd>
|
625
|
-
<dt>envelope_decay(flag), envelope_decay_loop(flag), length_counter_clock(flag)</dt>
|
626
|
-
<dd>It takes either :enable or :disable flag symbol. Disabled by default.</dd>
|
627
|
-
<dt>length(size)</dt>
|
628
|
-
<dd>Length number of the sound effect, between 1 and 254. It takes 16 by default.</dd>
|
629
|
-
<dt>pitch(control)</dt>
|
630
|
-
<dd>Control number of the sound effect, between 0 and 254. (This value is stil uncontrollable so far. Need to improve)</dd>
|
631
|
-
</dl>
|
126
|
+
Primarily, to let anti-piracy movement gain significant momentum. There are [countless ways out there](http://en.wikipedia.org/wiki/List_of_video_game_emulators#Consoles) that emulate .nes game, but very few that create .nes rom file without hassle. This is the original reason why @remore have developed Burn.
|
632
127
|
|
633
|
-
|
634
|
-
sound "attack" do
|
635
|
-
effect do
|
636
|
-
duty_cycle
|
637
|
-
velocity 15
|
638
|
-
envelope_decay :disable
|
639
|
-
length 10
|
640
|
-
pitch 200
|
641
|
-
envelope_decay_loop :disable
|
642
|
-
length_counter_clock :disable
|
643
|
-
end
|
644
|
-
end
|
645
|
-
```
|
128
|
+
Secondarily, to get back a lost love to video game programming. Having high-spec machine is not always happy to us, human beings. Sometimes we'd better to look back the old era where many constrains still exist. You might think it's silly, but I'm serious. It's crazy fun to struggle.
|
646
129
|
|
647
|
-
|
130
|
+
### Discussions and Conference Talks
|
648
131
|
|
649
|
-
|
132
|
+
A quick discussion at [Reddit.com](http://www.reddit.com/r/programming/comments/226vf0/build_your_own_nes_rom_file_with_ruby/)
|
650
133
|
|
651
|
-
|
134
|
+
[A Talk at RubyKaigi 2014](http://rubykaigi.org/2014/presentation/S-KeiSawada)
|
652
135
|
|
653
|
-
|
136
|
+
[Introduction at rubima(Rubyist Magazine)](http://magazine.rubyist.net/?0047-IntroductionToBurn)
|
654
137
|
|
655
138
|
### Helpful Folks
|
656
139
|
|
657
|
-
* Shiru -
|
658
|
-
* My friend from high school - I appreciate him for sending me fine-grained
|
140
|
+
* Shiru - This project had never been born if I had not found [this article](http://shiru.untergrund.net/articles/programming_nes_games_in_c.htm)
|
141
|
+
* My friend from high school - I appreciate him for sending me fine-grained reviews as always
|
142
|
+
* @josbrahol sent me a great pull request which contains many grammatical errors
|
143
|
+
* @kdb424 sent me a pull request to fix a typo
|
659
144
|
|
660
145
|
### License
|
661
146
|
|
@@ -663,6 +148,8 @@ GPLv3
|
|
663
148
|
|
664
149
|
### ToDos
|
665
150
|
|
151
|
+
Here are a few todo-memo for :nes mode.
|
152
|
+
|
666
153
|
* New VM Support
|
667
154
|
* compatiblize with enchant.js
|
668
155
|
* Enhancement of Fuel DSL
|
@@ -674,6 +161,6 @@ GPLv3
|
|
674
161
|
* Improvement of Internal Architecture
|
675
162
|
* make cc65 alternative in Ruby
|
676
163
|
* Other Feature To Be Supported
|
677
|
-
* make
|
164
|
+
* make Burn rubygem work with mruby(not soon)
|
678
165
|
* Fix bugs
|
679
166
|
* declaring 2x2 pattern works, however 2x1 pattern doesn't
|