gbtiles 0.1.1 → 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.
- checksums.yaml +4 -4
- data/README.md +22 -35
- data/bin/gbt +24 -0
- data/lib/gbtiles/gbm/cli/convert.rb +9 -1
- data/lib/gbtiles/gbm/export/asm/asm.h.erb +1 -1
- data/lib/gbtiles/gbm/export/asm/asm.rb +3 -0
- data/lib/gbtiles/gbm/export/asm/asm.s.erb +1 -1
- data/lib/gbtiles/gbm/import/gbm_file.rb +1 -1
- data/lib/gbtiles/gbm/map/objects/map_tile_data.rb +1 -3
- data/lib/gbtiles/gbr/cli/convert.rb +9 -1
- data/lib/gbtiles/gbr/export/asm/asm.h.erb +1 -1
- data/lib/gbtiles/gbr/export/asm/asm.rb +3 -0
- data/lib/gbtiles/gbr/export/asm/asm.s.erb +1 -1
- data/lib/gbtiles/gbr/import/gbr_file.rb +1 -1
- data/lib/gbtiles/gbr/tile_set/objects/tile_data.rb +1 -1
- data/lib/gbtiles/gbt/cli/convert.rb +58 -0
- data/lib/gbtiles/gbt/export/asm/asm.h.erb +11 -0
- data/lib/gbtiles/gbt/export/asm/asm.rb +63 -0
- data/lib/gbtiles/gbt/export/asm/asm.s.erb +20 -0
- data/lib/gbtiles/gbt/export/asm/channel.rb +156 -0
- data/lib/gbtiles/gbt/export/asm/channels/noise.rb +84 -0
- data/lib/gbtiles/gbt/export/asm/channels/pulse.rb +88 -0
- data/lib/gbtiles/gbt/export/asm/channels/wav.rb +105 -0
- data/lib/gbtiles/gbt/export/asm/converter.rb +37 -0
- data/lib/gbtiles/gbt/export/asm/effects/arpeggio.rb +16 -0
- data/lib/gbtiles/gbt/export/asm/effects/break_and_set_step.rb +16 -0
- data/lib/gbtiles/gbt/export/asm/effects/cut_note.rb +16 -0
- data/lib/gbtiles/gbt/export/asm/effects/jump.rb +16 -0
- data/lib/gbtiles/gbt/export/asm/effects/pan.rb +19 -0
- data/lib/gbtiles/gbt/export/asm/effects/speed.rb +22 -0
- data/lib/gbtiles/gbt/export/asm/effects/volume.rb +13 -0
- data/lib/gbtiles/gbt/import/mod_file.rb +65 -0
- data/lib/gbtiles/gbt/mod_data/mod_data.rb +21 -0
- data/lib/gbtiles/gbt/mod_data/pattern.rb +16 -0
- data/lib/gbtiles/gbt/mod_data/sample.rb +16 -0
- data/lib/gbtiles/helpers/data_type.rb +11 -0
- data/lib/gbtiles/version.rb +1 -1
- metadata +32 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4444836258ce775a299eda72809988b34fb9a204
|
4
|
+
data.tar.gz: e351147feef1937f31ec4594b24530404782d54e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e0e924baf471a0e6f6686488c2754c742b65a184c9ea48d877b970c6f7d94599d4f51d28eebf78f757d8c4af23ed6108c87ddb89a82100119bcb33c7431639
|
7
|
+
data.tar.gz: 1cc5072725025d7e8cd399d6b9db66f4f02b26a6f185c550115e182704c7374545213f6c0dfc0c0d0d6f44c690680034ad7a3b6d6c3df49a374f4dcdfaa83b51
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# GBTiles
|
2
2
|
|
3
|
-
[](https://travis-ci.org/bashaus/gbtiles)
|
4
|
+
[](https://codeclimate.com/github/bashaus/gbtiles)
|
5
|
+
[](https://codeclimate.com/github/bashaus/gbtiles/coverage)
|
4
6
|
|
5
7
|
Converts `.GBR` files created with
|
6
8
|
[Harry Mulder's Tile Designer (GBTD)](http://www.devrs.com/gb/hmgd/gbtd.html)
|
@@ -9,52 +11,37 @@ and `.GBM` files created with
|
|
9
11
|
to different formats for use with the Game Boy and
|
10
12
|
[GBDK](http://gbdk.sourceforge.net/).
|
11
13
|
|
12
|
-
|
14
|
+
<small>N.B.: Not all of the functionality provided by Harry Mulder's GBR and GBM
|
13
15
|
file format specification have been implemented; however there is enough to
|
14
|
-
generate the basics for tiles and maps
|
16
|
+
generate the basics for tiles and maps.</small>
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
gem install gbtiles
|
18
|
+
Also converts `.MOD` tracker files setup for the Game Boy for use with
|
19
|
+
[AntonioND's GBT Player](https://github.com/AntonioND/gbt-player).
|
19
20
|
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
### Help
|
23
|
-
|
24
|
-
To view help information for the GBR or GBM commands, simply type one of the
|
25
|
-
following:
|
26
21
|
|
27
|
-
gbr --help
|
28
|
-
gbm --help
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
Converts a Tile Designer file `*.gbr` to an ASM file `*.s` and generates
|
33
|
-
a C file `*.h` for convenience.
|
34
|
-
|
35
|
-
gbr convert --output "sample.s" sample.gbr
|
23
|
+
## Installation
|
36
24
|
|
37
|
-
|
38
|
-
output file `.s` will default to `STDOUT`.
|
25
|
+
Install globally:
|
39
26
|
|
40
|
-
|
27
|
+
gem install gbtiles
|
41
28
|
|
42
|
-
|
43
|
-
a C file `*.h` for convenience.
|
29
|
+
Include in your `Gemfile`:
|
44
30
|
|
45
|
-
|
31
|
+
gem "gbtiles", "~> 0.2.0"
|
46
32
|
|
47
|
-
You can also specify the target layer of a map specifying a layer flag.
|
48
|
-
Acceptable values: `bkg` for the background, `win` for the window overlay or
|
49
|
-
`sprite` for sprites. Default value: `bkg`.
|
50
33
|
|
51
|
-
gbm convert --output "sample.s" --layer=bkg sample.gbm
|
52
34
|
|
53
|
-
|
54
|
-
output file `.s` will default to `STDOUT`.
|
35
|
+
## Usage
|
55
36
|
|
56
|
-
|
37
|
+
To view help information for each of the commands, simply type one of the
|
38
|
+
following:
|
57
39
|
|
58
|
-
|
40
|
+
# Converts .GBM files to different formats for the Game Boy
|
41
|
+
gbm convert --help
|
42
|
+
|
43
|
+
# Converts .GBR files to different formats for the Game Boy
|
44
|
+
gbr convert --help
|
59
45
|
|
60
|
-
|
46
|
+
# Converts .MOD files to different formats for the Game Boy
|
47
|
+
gbt convert --help
|
data/bin/gbt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "gli"
|
3
|
+
include GLI::App
|
4
|
+
|
5
|
+
require "gbtiles/version"
|
6
|
+
require "gbtiles/gbt/cli/convert"
|
7
|
+
|
8
|
+
program_desc "Converts .MOD files to different formats for the Game Boy"
|
9
|
+
|
10
|
+
version GBTiles::VERSION
|
11
|
+
|
12
|
+
pre do |global,command,options,args|
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
post do |global,command,options,args|
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
on_error do |exception|
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
exit run(ARGV)
|
@@ -2,13 +2,16 @@ require "gbtiles/helpers/data_type"
|
|
2
2
|
require "gbtiles/gbm/import/gbm_file"
|
3
3
|
require "gbtiles/gbm/export/asm/asm"
|
4
4
|
|
5
|
-
desc "
|
5
|
+
desc "Converts .GBM files to different formats for the Game Boy"
|
6
6
|
arg_name "input"
|
7
7
|
command :convert do |c|
|
8
8
|
|
9
9
|
c.desc "Output filename [*.s]"
|
10
10
|
c.flag :output
|
11
11
|
|
12
|
+
c.desc "ROM Bank"
|
13
|
+
c.flag :bank
|
14
|
+
|
12
15
|
c.desc "Layer type of the map [bkg, win, sprite]"
|
13
16
|
c.flag :layer,
|
14
17
|
:must_match => [:bkg, :win, :sprite],
|
@@ -39,6 +42,11 @@ command :convert do |c|
|
|
39
42
|
|
40
43
|
# Do export
|
41
44
|
export = GBTiles::GBM::Export::ASM::ASM.new
|
45
|
+
|
46
|
+
if !options[:bank].nil? then
|
47
|
+
export.bank = options[:bank].to_i
|
48
|
+
end
|
49
|
+
|
42
50
|
export.map_set = import.map_set
|
43
51
|
export.layer = options[:layer]
|
44
52
|
export.write(output_file)
|
@@ -12,7 +12,7 @@
|
|
12
12
|
// Helper: Map dimensions
|
13
13
|
#define <%= map_export_settings.label_name %>Width <%= map.width %>
|
14
14
|
#define <%= map_export_settings.label_name %>Height <%= map.height %>
|
15
|
-
#define <%= map_export_settings.label_name %>Bank <%=
|
15
|
+
#define <%= map_export_settings.label_name %>Bank <%= bank %>
|
16
16
|
|
17
17
|
// Extern: <%= map_export_settings.label_name %>
|
18
18
|
extern unsigned char <%= map_export_settings.label_name %>[];
|
@@ -9,6 +9,7 @@ module GBTiles
|
|
9
9
|
class ASM
|
10
10
|
include ERB::Util
|
11
11
|
|
12
|
+
attr_accessor :bank
|
12
13
|
attr_accessor :map_set
|
13
14
|
attr_accessor :layer
|
14
15
|
|
@@ -23,6 +24,8 @@ module GBTiles
|
|
23
24
|
if @layer.nil? then
|
24
25
|
raise "Missing required layer (bkg, win, sprite)"
|
25
26
|
end
|
27
|
+
|
28
|
+
@bank ||= @map_set.map_export_settings.first.bank
|
26
29
|
end
|
27
30
|
|
28
31
|
def render_s
|
@@ -6,7 +6,7 @@
|
|
6
6
|
; <%= map_set.producer.first.name %> (v<%= map_set.producer.first.version %>)
|
7
7
|
; <%= map_set.producer.first.info %>
|
8
8
|
|
9
|
-
.area _CODE_<%=
|
9
|
+
.area _CODE_<%= bank -%>
|
10
10
|
|
11
11
|
<% map_set.map.each do |map| -%>
|
12
12
|
<% map_tile_data = map_set.map_tile_data(map.master_id).first -%>
|
@@ -21,9 +21,7 @@ module GBTiles
|
|
21
21
|
number = 0.chr + number # Convert from 24-bit to 32-bit
|
22
22
|
number = number.unpack("N").first # Unpack integer
|
23
23
|
|
24
|
-
object.records.
|
25
|
-
GBTiles::GBM::Map::Objects::MapTileDataRecord.initFromBitString(number)
|
26
|
-
)
|
24
|
+
object.records << GBTiles::GBM::Map::Objects::MapTileDataRecord.initFromBitString(number)
|
27
25
|
end
|
28
26
|
|
29
27
|
object
|
@@ -2,13 +2,16 @@ require "gbtiles/helpers/data_type"
|
|
2
2
|
require "gbtiles/gbr/import/gbr_file"
|
3
3
|
require "gbtiles/gbr/export/asm/asm"
|
4
4
|
|
5
|
-
desc "
|
5
|
+
desc "Converts .GBR files to different formats for the Game Boy"
|
6
6
|
arg_name "input"
|
7
7
|
command :convert do |c|
|
8
8
|
|
9
9
|
c.desc "Output filename [*.s]"
|
10
10
|
c.flag :output
|
11
11
|
|
12
|
+
c.desc "ROM Bank"
|
13
|
+
c.flag :bank
|
14
|
+
|
12
15
|
c.action do |global_options,options,args|
|
13
16
|
# Prepare input file
|
14
17
|
if !args[0].nil? then
|
@@ -34,6 +37,11 @@ command :convert do |c|
|
|
34
37
|
|
35
38
|
# Do export
|
36
39
|
export = GBTiles::GBR::Export::ASM::ASM.new
|
40
|
+
|
41
|
+
if !options[:bank].nil? then
|
42
|
+
export.bank = options[:bank].to_i
|
43
|
+
end
|
44
|
+
|
37
45
|
export.tile_set = import.tile_set
|
38
46
|
export.write(output_file)
|
39
47
|
output_file.close
|
@@ -7,6 +7,7 @@ module GBTiles
|
|
7
7
|
class ASM
|
8
8
|
include ERB::Util
|
9
9
|
|
10
|
+
attr_accessor :bank
|
10
11
|
attr_accessor :tile_set
|
11
12
|
|
12
13
|
def initialize
|
@@ -16,6 +17,8 @@ module GBTiles
|
|
16
17
|
if @tile_set.nil? then
|
17
18
|
raise "Missing required tile set"
|
18
19
|
end
|
20
|
+
|
21
|
+
@bank ||= @tile_set.tile_export.first.bank
|
19
22
|
end
|
20
23
|
|
21
24
|
def render_s
|
@@ -6,7 +6,7 @@
|
|
6
6
|
; <%= tile_set.producer.first.name %> (v<%= tile_set.producer.first.version %>)
|
7
7
|
; <%= tile_set.producer.first.info %>
|
8
8
|
|
9
|
-
.area _CODE_<%=
|
9
|
+
.area _CODE_<%= bank %>
|
10
10
|
|
11
11
|
.globl _<%= tile_export.label_name %>
|
12
12
|
.dw _<%= tile_export.label_name %>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "gbtiles/helpers/data_type"
|
2
|
+
require "gbtiles/gbt/import/mod_file"
|
3
|
+
require "gbtiles/gbt/export/asm/asm"
|
4
|
+
|
5
|
+
desc "Converts .MOD files to different formats for the Game Boy"
|
6
|
+
arg_name "input"
|
7
|
+
command :convert do |c|
|
8
|
+
|
9
|
+
c.desc "Output filename [*.s]"
|
10
|
+
c.flag :output
|
11
|
+
|
12
|
+
c.desc "ROM Bank"
|
13
|
+
c.default_value 2
|
14
|
+
c.flag :bank
|
15
|
+
|
16
|
+
c.desc "Label"
|
17
|
+
c.flag :label
|
18
|
+
|
19
|
+
c.action do |global_options,options,args|
|
20
|
+
# Prepare input file
|
21
|
+
if !args[0].nil? then
|
22
|
+
# Use file
|
23
|
+
input_file = File.open(args[0], "rb")
|
24
|
+
else
|
25
|
+
# Use STDIN
|
26
|
+
input_file = $stdin
|
27
|
+
end
|
28
|
+
|
29
|
+
# Prepare output file
|
30
|
+
if !options[:output].nil? then
|
31
|
+
# Use file
|
32
|
+
output_file = File.open(options[:output], "w")
|
33
|
+
else
|
34
|
+
# Use STDOUT
|
35
|
+
output_file = $stdout
|
36
|
+
end
|
37
|
+
|
38
|
+
# Do import
|
39
|
+
import = GBTiles::GBT::Import::MODFile.open(input_file)
|
40
|
+
input_file.close
|
41
|
+
|
42
|
+
# Do export
|
43
|
+
export = GBTiles::GBT::Export::ASM::ASM.new
|
44
|
+
export.bank = options[:bank].to_i
|
45
|
+
export.mod_data = import.mod_data
|
46
|
+
|
47
|
+
if !options[:label].nil? then
|
48
|
+
# Use label from CLI
|
49
|
+
export.label = options[:label]
|
50
|
+
elsif !options[:output].nil? then
|
51
|
+
# Use filename
|
52
|
+
export.label = File.basename(options[:output], ".*")
|
53
|
+
end
|
54
|
+
|
55
|
+
export.write(output_file)
|
56
|
+
output_file.close
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "gbtiles/gbt/export/asm/converter"
|
2
|
+
require "erb"
|
3
|
+
|
4
|
+
module GBTiles
|
5
|
+
module GBT
|
6
|
+
module Export
|
7
|
+
module ASM
|
8
|
+
class ASM
|
9
|
+
include ERB::Util
|
10
|
+
|
11
|
+
attr_accessor :bank
|
12
|
+
attr_accessor :label
|
13
|
+
attr_accessor :mod_data
|
14
|
+
attr_accessor :converter
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@converter = GBTiles::GBT::Export::ASM::Converter.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def prerender
|
21
|
+
if !@bank.is_a? Numeric then
|
22
|
+
raise "Bank must be numeric"
|
23
|
+
end
|
24
|
+
|
25
|
+
if @mod_data.nil? then
|
26
|
+
raise "Missing required mod data"
|
27
|
+
end
|
28
|
+
|
29
|
+
@label ||= mod_data.name
|
30
|
+
end
|
31
|
+
|
32
|
+
def render_s
|
33
|
+
prerender
|
34
|
+
|
35
|
+
template = File.open(File.join(__dir__, "asm.s.erb"), "r").read
|
36
|
+
|
37
|
+
ERB.new(template, nil, "-").result(binding)
|
38
|
+
end
|
39
|
+
|
40
|
+
def render_h
|
41
|
+
prerender
|
42
|
+
|
43
|
+
template = File.open(File.join(__dir__, "asm.h.erb"), "r").read
|
44
|
+
|
45
|
+
ERB.new(template, nil, "-").result(binding)
|
46
|
+
end
|
47
|
+
|
48
|
+
def write output_stream
|
49
|
+
output_stream.write(render_s)
|
50
|
+
|
51
|
+
if output_stream.is_a? File then
|
52
|
+
header_filename = "#{File.basename(output_stream.path, ".s")}.h"
|
53
|
+
header_path = "#{File.dirname(File.expand_path(output_stream.path))}/#{header_filename}"
|
54
|
+
header_stream = File.open(header_path, "w")
|
55
|
+
header_stream.write(render_h)
|
56
|
+
header_stream.close
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
; .S created with
|
2
|
+
; GBTiles Ruby Gem (v<%= GBTiles::VERSION %>) - GBT
|
3
|
+
|
4
|
+
.area _CODE_<%= bank -%>
|
5
|
+
|
6
|
+
<% for i in 0..(mod_data.pattern_table.max) do %>
|
7
|
+
<%= "_#{label}#{i}" %>:
|
8
|
+
<% for j in 0..63 -%>
|
9
|
+
.db <%= converter.convert(mod_data.patterns[i].rows[j]) %>
|
10
|
+
<% end -%>
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
.globl <%= "_#{label}" %>
|
14
|
+
.dw <%= "_#{label}" %>
|
15
|
+
|
16
|
+
<%= "_#{label}" %>:
|
17
|
+
<% for i in 0..(mod_data.song_length - 1) -%>
|
18
|
+
.dw <%= "_#{label}#{i}" %>
|
19
|
+
<% end -%>
|
20
|
+
.dw 0x0000
|