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/README.md
ADDED
@@ -0,0 +1,467 @@
|
|
1
|
+
# Burn
|
2
|
+
|
3
|
+
Burn is a free and open source framework that allows you to create 8-bit flavored application using Ruby DSL.
|
4
|
+
|
5
|
+
```ruby
|
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)
|
14
|
+
|
15
|
+
Here is another example. With Fuel DSL, you can even compose background music in 1 minute.
|
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.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
declare do
|
42
|
+
star <<-EOH
|
43
|
+
|
44
|
+
11
|
45
|
+
11
|
46
|
+
1111
|
47
|
+
1111
|
48
|
+
1111111111111111
|
49
|
+
11111111111111
|
50
|
+
111111111111
|
51
|
+
1111111111
|
52
|
+
11111111
|
53
|
+
11111111
|
54
|
+
11111111
|
55
|
+
1111 1111
|
56
|
+
11 11
|
57
|
+
1 1
|
58
|
+
|
59
|
+
EOH
|
60
|
+
end
|
61
|
+
|
62
|
+
scene do
|
63
|
+
main_loop <<-EOH
|
64
|
+
star.x=20
|
65
|
+
star.y-=3
|
66
|
+
sprite "star"
|
67
|
+
EOH
|
68
|
+
end
|
69
|
+
|
70
|
+
```
|
71
|
+
|
72
|
+
![star animated gif](http://k.swd.cc/burn/resource/screenshot/star.gif)
|
73
|
+
|
74
|
+
Please visit [our project page](http://k.swd.cc/burn/) for more example.
|
75
|
+
|
76
|
+
## Table Of Contents
|
77
|
+
|
78
|
+
* [Getting Started](#getting-started)
|
79
|
+
* [How It Works](#how-it-works)
|
80
|
+
* [Installation](#installation)
|
81
|
+
* [Quick Start](#quick-start)
|
82
|
+
* [Fuel DSL Methods](#fuel-dsl-methods)
|
83
|
+
* [Scene](#scene)
|
84
|
+
* [Sound](#sound)
|
85
|
+
* [Music](#music)
|
86
|
+
* [Declare](#declare)
|
87
|
+
* [Burning Fuel DSL In Action](#burning-fuel-dsl-in-action)
|
88
|
+
* [Programming With .rrb(Restricted Ruby) Syntax](#programming-with-rrbrestricted-ruby-syntax)
|
89
|
+
* [Notes](#notes)
|
90
|
+
* [Personal Motivation](#personal-motivation)
|
91
|
+
* [Helpful Folks](#helpful-folks)
|
92
|
+
* [License](#license)
|
93
|
+
* [ToDos](#todos)
|
94
|
+
|
95
|
+
## Getting Started
|
96
|
+
|
97
|
+
### How It Works
|
98
|
+
|
99
|
+
Internally, burn contains cc65 executables inside its gemfile and calls them to compile. Main workflow is as follows.
|
100
|
+
|
101
|
+
- translate ruby DSL file into c source code
|
102
|
+
- compile them to make executable(main.out) by calling cc65
|
103
|
+
- provide emulator(JSNES) for rpaid application development
|
104
|
+
|
105
|
+
This means what burn can do is always less than what cc65 can do.
|
106
|
+
|
107
|
+
### Installation
|
108
|
+
|
109
|
+
gem install burn
|
110
|
+
|
111
|
+
### Quick Start
|
112
|
+
|
113
|
+
echo "scene do{ label 'hello world'}" > main.rb
|
114
|
+
burn -p # -p: open up emulator right after compilation
|
115
|
+
|
116
|
+
## Fuel DSL Methods
|
117
|
+
|
118
|
+
Currently following DSL Methods are available. If you are newbie here, kindly visit [project page](http://k.swd.cc/burn/) first to see what you can do with Burn and Fuel DSL.
|
119
|
+
|
120
|
+
* [Scene](#scene)
|
121
|
+
* [Sound](#sound)
|
122
|
+
* [Music](#music)
|
123
|
+
* [Declare](#declare)
|
124
|
+
|
125
|
+
### Scene
|
126
|
+
|
127
|
+
#### label(string, x=0, y=1)
|
128
|
+
|
129
|
+
The label method can be used in a scene to display static string.
|
130
|
+
|
131
|
+
<dl>
|
132
|
+
<dt>string String</dt>
|
133
|
+
<dd>Static string to display.</dd>
|
134
|
+
<dt>x Number</dt>
|
135
|
+
<dd>The horizontal coordinate to display, between 0 and 31.</dd>
|
136
|
+
<dt>y Number</dt>
|
137
|
+
<dd>The vertical coordinate to display, between 0 and 28.</dd>
|
138
|
+
</dl>
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
scene do
|
142
|
+
label "Hello, World!"
|
143
|
+
label "Hello, World!", 4, 5
|
144
|
+
end
|
145
|
+
```
|
146
|
+
|
147
|
+
#### fade_in, fade_out
|
148
|
+
|
149
|
+
These methods can be used in a scene to fade in or out.
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
scene do
|
153
|
+
label "Hello"
|
154
|
+
fade_in
|
155
|
+
main_loop
|
156
|
+
fade_out
|
157
|
+
goto "next"
|
158
|
+
end
|
159
|
+
```
|
160
|
+
|
161
|
+
#### play(song_title)
|
162
|
+
|
163
|
+
The play method can be used in a scene to play music.
|
164
|
+
|
165
|
+
<dl>
|
166
|
+
<dt>song_title String</dt>
|
167
|
+
<dd>Song title to play.</dd>
|
168
|
+
</dl>
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
scene do
|
172
|
+
play "battle"
|
173
|
+
stop
|
174
|
+
end
|
175
|
+
|
176
|
+
music "battle" do
|
177
|
+
channel "string" do
|
178
|
+
g :dotted
|
179
|
+
g :eighth
|
180
|
+
c :half
|
181
|
+
end
|
182
|
+
end
|
183
|
+
```
|
184
|
+
|
185
|
+
#### stop
|
186
|
+
|
187
|
+
The stop method can be used in a scene to stop music.
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
scene do
|
191
|
+
stop "battle"
|
192
|
+
end
|
193
|
+
```
|
194
|
+
|
195
|
+
#### color(palette, color, lightness=:lighter)
|
196
|
+
|
197
|
+
The color method can be used in a scene to pick a color and set it to specific palette.
|
198
|
+
|
199
|
+
<dl>
|
200
|
+
<dt>palette Symbol</dt>
|
201
|
+
<dd>Palette to set.
|
202
|
+
<table>
|
203
|
+
<tr>
|
204
|
+
<th>Palette Symbol</th>
|
205
|
+
<th>Description</th>
|
206
|
+
</tr>
|
207
|
+
<tr>
|
208
|
+
<td>:bg</td>
|
209
|
+
<td>Background color</td>
|
210
|
+
</tr>
|
211
|
+
<tr>
|
212
|
+
<td>:text</td>
|
213
|
+
<td>Foreground color</td>
|
214
|
+
</tr>
|
215
|
+
<tr>
|
216
|
+
<td>:palette_x1, :palette_x2, :palette_x3</td>
|
217
|
+
<td>Colors for :palette_x</td>
|
218
|
+
</tr>
|
219
|
+
<tr>
|
220
|
+
<td>:palette_y1, :palette_y2, :palette_y3</td>
|
221
|
+
<td>Colors for :palette_y</td>
|
222
|
+
</tr>
|
223
|
+
<tr>
|
224
|
+
<td>:palette_z1, :palette_z2, :palette_z3</td>
|
225
|
+
<td>Colors for :palette_z</td>
|
226
|
+
</tr>
|
227
|
+
<tr>
|
228
|
+
<td>:sprite</td>
|
229
|
+
<td>Sprite color</td>
|
230
|
+
</tr>
|
231
|
+
</table>
|
232
|
+
</dd>
|
233
|
+
<dt>color Symbol</dt>
|
234
|
+
<dd>Color to set. Available color pattern is shown below.<br />
|
235
|
+
<img src="http://www.thealmightyguru.com/Games/Hacking/Wiki/images/e/e8/Palette_NTSC.png">
|
236
|
+
<table>
|
237
|
+
<tr>
|
238
|
+
<th>Color Symbol</th>
|
239
|
+
</tr>
|
240
|
+
<tr><td>:white</td></tr>
|
241
|
+
<tr><td>:lightblue</td></tr>
|
242
|
+
<tr><td>:blue</td></tr>
|
243
|
+
<tr><td>:purple</td></tr>
|
244
|
+
<tr><td>:pink</td></tr>
|
245
|
+
<tr><td>:red</td></tr>
|
246
|
+
<tr><td>:deepred</td></tr>
|
247
|
+
<tr><td>:orange</td></tr>
|
248
|
+
<tr><td>:lightorange</td></tr>
|
249
|
+
<tr><td>:darkgreen</td></tr>
|
250
|
+
<tr><td>:green</td></tr>
|
251
|
+
<tr><td>:lightgreen</td></tr>
|
252
|
+
<tr><td>:bluegreen</td></tr>
|
253
|
+
<tr><td>:gray</td></tr>
|
254
|
+
<tr><td>:black</td></tr>
|
255
|
+
</table>
|
256
|
+
</dd>
|
257
|
+
<dt>lightness Symbol</dt>
|
258
|
+
<dd>Lightness of the color to set. `:darkest`, `:darker`, `:lighter` and `:lightest` can be set.</dd>
|
259
|
+
</dl>
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
scene do
|
263
|
+
label "Hello, World!"
|
264
|
+
color :text, :pink, :darker
|
265
|
+
end
|
266
|
+
```
|
267
|
+
|
268
|
+
#### wait(interval)
|
269
|
+
|
270
|
+
The wait method can be used in a scene to pause for certain period of time.
|
271
|
+
|
272
|
+
<dl>
|
273
|
+
<dt>interval Fixnum</dt>
|
274
|
+
<dd>Period of time to pause.</dd>
|
275
|
+
</dl>
|
276
|
+
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
scene do
|
280
|
+
label "foobar"
|
281
|
+
fade_out
|
282
|
+
wait 100
|
283
|
+
goto "somewhere"
|
284
|
+
end
|
285
|
+
```
|
286
|
+
|
287
|
+
#### goto(scene_name)
|
288
|
+
|
289
|
+
The goto method can be used in a scene to jump the scene specified.
|
290
|
+
|
291
|
+
<dl>
|
292
|
+
<dt>scene_name String</dt>
|
293
|
+
<dd>Destination to jump.</dd>
|
294
|
+
</dl>
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
scene "first" do
|
298
|
+
label "good morning"
|
299
|
+
goto "second"
|
300
|
+
end
|
301
|
+
|
302
|
+
scene "second" do
|
303
|
+
label "hi there"
|
304
|
+
end
|
305
|
+
```
|
306
|
+
|
307
|
+
#### inline(code)
|
308
|
+
|
309
|
+
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.
|
310
|
+
|
311
|
+
<dl>
|
312
|
+
<dt>code String</dt>
|
313
|
+
<dd>C code to inject.</dd>
|
314
|
+
</dl>
|
315
|
+
|
316
|
+
```ruby
|
317
|
+
scene do
|
318
|
+
inline "x=1+2;"
|
319
|
+
end
|
320
|
+
```
|
321
|
+
|
322
|
+
#### screen(map, vars)
|
323
|
+
|
324
|
+
The screen method can be used to inflate map data to a scene.
|
325
|
+
|
326
|
+
<dl>
|
327
|
+
<dt>map String</dt>
|
328
|
+
<dd>Map data consists of hash keys of pattern design.</dd>
|
329
|
+
<dt>vars Hash</dt>
|
330
|
+
<dd>A list of pattern designs.</dd>
|
331
|
+
</dl>
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
scene do
|
335
|
+
screen <<-EOH, { A:"tile", B:"wave", C:"mountain"}
|
336
|
+
|
337
|
+
AAAA AA AAA AAA AA A
|
338
|
+
AA A AA AA AA AA AA AA A
|
339
|
+
AA A AA AA AA AA AAA
|
340
|
+
AAAAA AA AA AA AA AA
|
341
|
+
AA A AA AAAAAAA AA AAA
|
342
|
+
AA A AA AA AA AA AA AA A
|
343
|
+
AAAA AAAA AA AA AAA AA A
|
344
|
+
|
345
|
+
BB BB BB BBB BBBBB
|
346
|
+
BB BB BB BB BB BB BB
|
347
|
+
BB BB BB BB BB BB BB BB
|
348
|
+
BB BB BB BB BBBBBBB BBBB
|
349
|
+
BB BB BB BB BB BB
|
350
|
+
BB BB BB BB BB BB
|
351
|
+
EOH
|
352
|
+
end
|
353
|
+
```
|
354
|
+
|
355
|
+
#### sound(effect_name)
|
356
|
+
|
357
|
+
The sound method in a scene can be used to play sound effect.
|
358
|
+
|
359
|
+
<dl>
|
360
|
+
<dt>effect_name String</dt>
|
361
|
+
<dd>Name of sound effect to play.</dd>
|
362
|
+
</dl>
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
scene do
|
366
|
+
sound "dead"
|
367
|
+
end
|
368
|
+
|
369
|
+
sound "dead" do
|
370
|
+
effect do
|
371
|
+
velocity 15
|
372
|
+
length 5
|
373
|
+
pitch 200
|
374
|
+
end
|
375
|
+
end
|
376
|
+
```
|
377
|
+
|
378
|
+
#### paint(dest, palette)
|
379
|
+
|
380
|
+
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.
|
381
|
+
|
382
|
+
<dl>
|
383
|
+
<dt>dest Range</dt>
|
384
|
+
<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>
|
385
|
+
<dt>palette Symbol</dt>
|
386
|
+
<dd>Palette symbol to apply. Kindly refer candidate symbols listed at <a href="#colorpalette-color-lightnesslighter">color</a> section.</dd>
|
387
|
+
</dl>
|
388
|
+
|
389
|
+
```ruby
|
390
|
+
scene "title" do
|
391
|
+
color :palette_x1, :deepred, :darker
|
392
|
+
paint range("44px", "5px", "120px", "3px"), :palette_x # range takes String parameter
|
393
|
+
|
394
|
+
color :palette_y2, :pink, :darkest
|
395
|
+
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.
|
396
|
+
end
|
397
|
+
```
|
398
|
+
|
399
|
+
#### main_loop(rrb_source=nil)
|
400
|
+
|
401
|
+
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).
|
402
|
+
|
403
|
+
<dl>
|
404
|
+
<dt>rrb_source String</dt>
|
405
|
+
<dd>Source code written in .rrb(Resticted Ruby) syntax.</dd>
|
406
|
+
</dl>
|
407
|
+
|
408
|
+
```ruby
|
409
|
+
scene "title" do
|
410
|
+
color :palette_x1, :deepred, :darker
|
411
|
+
paint range("44px", "5px", "120px", "3px"), :palette_x # range takes String parameter
|
412
|
+
|
413
|
+
color :palette_y2, :pink, :darkest
|
414
|
+
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.
|
415
|
+
end
|
416
|
+
```
|
417
|
+
|
418
|
+
### Sound
|
419
|
+
|
420
|
+
TBD
|
421
|
+
|
422
|
+
### Music
|
423
|
+
|
424
|
+
TBD
|
425
|
+
|
426
|
+
### Declare
|
427
|
+
|
428
|
+
TBD
|
429
|
+
|
430
|
+
## Burning Fuel DSL In Action
|
431
|
+
|
432
|
+
### Programming With .rrb(Restricted Ruby) Syntax
|
433
|
+
|
434
|
+
TBD(articles about #show, #sprite, #rand and #is_pressed are coming very soon)
|
435
|
+
|
436
|
+
## Notes
|
437
|
+
|
438
|
+
### Personal Motivation
|
439
|
+
|
440
|
+
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.
|
441
|
+
|
442
|
+
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.
|
443
|
+
|
444
|
+
### Helpful Folks
|
445
|
+
|
446
|
+
* 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)
|
447
|
+
|
448
|
+
### License
|
449
|
+
|
450
|
+
GPLv3
|
451
|
+
|
452
|
+
### ToDos
|
453
|
+
|
454
|
+
* New VM Support
|
455
|
+
* compatiblize with enchant.js
|
456
|
+
* Enhancement of Fuel DSL
|
457
|
+
* for Screen, support screen scroll and simple sprite
|
458
|
+
* for Screen, adding .bmp and .png support to make designing pattern table easier
|
459
|
+
* for Sound, add triangle wave and noise effect
|
460
|
+
* for Music, add custom instrument DSL
|
461
|
+
* for Declare, support string and boolean declaration(currently only number and pattern table is supported)
|
462
|
+
* Improvement of Internal Architecture
|
463
|
+
* make cc65 alternative in Ruby
|
464
|
+
* Other Feature To Be Supported
|
465
|
+
* make burn rubygem work with mruby(not soon)
|
466
|
+
* Fix bugs
|
467
|
+
* declaring 2x2 pattern works, however 2x1 pattern doesn't
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# TBD for test or build
|
data/bin/burn
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if !ARGV.index('-d') then
|
4
|
+
require 'rubygems'
|
5
|
+
else
|
6
|
+
Encoding.default_external = 'UTF-8'
|
7
|
+
['..', '../lib'].each do |path|
|
8
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), path))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'burn'
|
13
|
+
include Burn
|
14
|
+
BurnTasks.start
|
data/lib/burn/builder.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
module Burn
|
2
|
+
class Builder
|
3
|
+
include Dsl
|
4
|
+
include Generator
|
5
|
+
include Debug
|
6
|
+
|
7
|
+
def initialize(workspace_root)
|
8
|
+
@workspace_root = workspace_root
|
9
|
+
|
10
|
+
@game_generator = CSource.new(@workspace_root)
|
11
|
+
@music_generator = AssemblyMusic.new(@workspace_root)
|
12
|
+
@sound_effect_generator = AssemblySoundEffect.new(@workspace_root)
|
13
|
+
end
|
14
|
+
|
15
|
+
def verbose(flag)
|
16
|
+
Debug::Logger.new.enabled flag
|
17
|
+
end
|
18
|
+
|
19
|
+
def load(dsl_raw_text)
|
20
|
+
self.instance_eval dsl_raw_text
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate
|
24
|
+
@game_generator.generate
|
25
|
+
@music_generator.generate
|
26
|
+
@sound_effect_generator.generate
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(method_symbol, *args, &block)
|
30
|
+
log :method_symbol=>method_symbol, :args=>args, :block=>block
|
31
|
+
if method_symbol == :music then
|
32
|
+
Music.new(args[0], @music_generator.get_context).instance_eval(&block)
|
33
|
+
|
34
|
+
elsif method_symbol == :scene then
|
35
|
+
# preprocess
|
36
|
+
args[0] = "main" if args[0].nil?
|
37
|
+
@game_generator.get_context.instance_exec args[0], &lambda{|resource_name|
|
38
|
+
[
|
39
|
+
"",
|
40
|
+
"//#{resource_name} label starts",
|
41
|
+
"#{resource_name}:"
|
42
|
+
].each {|p| @code_blocks.push p}
|
43
|
+
}
|
44
|
+
|
45
|
+
# execute dsls
|
46
|
+
Scene.new(args[0], @game_generator.get_context).instance_eval(&block)
|
47
|
+
|
48
|
+
# postprocess - To deal with the case of on_enter_frame not found, adding while loop at the end of program
|
49
|
+
@game_generator.get_context.instance_exec {@code_blocks.push "ppu_on_all();", "while(1);"}
|
50
|
+
|
51
|
+
elsif method_symbol == :declare then
|
52
|
+
Declare.new(args[0], @game_generator.get_context).instance_eval(&block)
|
53
|
+
|
54
|
+
elsif method_symbol == :sound then
|
55
|
+
Sound.new(args[0], @sound_effect_generator.get_context).instance_eval(&block)
|
56
|
+
|
57
|
+
# postprocess
|
58
|
+
@game_generator.get_context.instance_exec(@sound_effect_generator.resources.count-1) do |count|
|
59
|
+
@global.push "#define SFX_#{args[0].upcase} #{count.to_s}"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|