gbtiles 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/bin/gbm +0 -3
- data/bin/gbr +0 -3
- data/lib/gbtiles/gbm/cli/convert.rb +8 -17
- data/lib/gbtiles/gbm/export/asm/asm.h.erb +3 -3
- data/lib/gbtiles/gbm/export/asm/asm.rb +7 -1
- data/lib/gbtiles/gbm/export/asm/asm.s.erb +4 -4
- data/lib/gbtiles/gbm/import/gbm_file.rb +24 -13
- data/lib/gbtiles/gbm/layer.rb +9 -0
- data/lib/gbtiles/gbm/map/map_set.rb +22 -11
- data/lib/gbtiles/gbm/map/object.rb +0 -5
- data/lib/gbtiles/gbm/map/object_type.rb +8 -8
- data/lib/gbtiles/gbm/map/objects/map.rb +1 -14
- data/lib/gbtiles/gbm/map/objects/map_export_settings.rb +1 -28
- data/lib/gbtiles/gbm/map/objects/map_settings.rb +1 -26
- data/lib/gbtiles/gbm/map/objects/map_tile_data.rb +1 -2
- data/lib/gbtiles/gbm/map/objects/map_tile_data_record.rb +0 -9
- data/lib/gbtiles/gbm/map/objects/producer.rb +2 -7
- data/lib/gbtiles/gbm/map/objects/unknown.rb +0 -1
- data/lib/gbtiles/gbr/cli/convert.rb +2 -19
- data/lib/gbtiles/gbr/export/asm/asm.rb +0 -1
- data/lib/gbtiles/gbr/import/gbr_file.rb +37 -21
- data/lib/gbtiles/gbr/tile_set/color_set.rb +6 -6
- data/lib/gbtiles/gbr/tile_set/export_type.rb +7 -7
- data/lib/gbtiles/gbr/tile_set/object.rb +0 -3
- data/lib/gbtiles/gbr/tile_set/object_type.rb +10 -10
- data/lib/gbtiles/gbr/tile_set/objects/palettes.rb +1 -10
- data/lib/gbtiles/gbr/tile_set/objects/producer.rb +1 -6
- data/lib/gbtiles/gbr/tile_set/objects/tile_data.rb +2 -13
- data/lib/gbtiles/gbr/tile_set/objects/tile_export.rb +1 -42
- data/lib/gbtiles/gbr/tile_set/objects/tile_import.rb +1 -18
- data/lib/gbtiles/gbr/tile_set/objects/tile_pal.rb +1 -10
- data/lib/gbtiles/gbr/tile_set/objects/tile_settings.rb +1 -22
- data/lib/gbtiles/gbr/tile_set/objects/unknown.rb +0 -1
- data/lib/gbtiles/gbr/tile_set/sgb_palettes.rb +7 -7
- data/lib/gbtiles/gbr/tile_set/split_order.rb +6 -6
- data/lib/gbtiles/gbr/tile_set/tile_set.rb +20 -9
- data/lib/gbtiles/{data_type.rb → helpers/data_type.rb} +19 -11
- data/lib/gbtiles/version.rb +1 -1
- metadata +47 -4
@@ -5,46 +5,21 @@ module GBTiles
|
|
5
5
|
class MapSettings < GBTiles::GBM::Map::Object
|
6
6
|
|
7
7
|
attr_accessor :form_width
|
8
|
-
@form_width
|
9
|
-
|
10
8
|
attr_accessor :form_height
|
11
|
-
@form_height
|
12
|
-
|
13
9
|
attr_accessor :form_maximized
|
14
|
-
@form_maximized
|
15
|
-
|
16
10
|
attr_accessor :info_panel
|
17
|
-
@info_panel
|
18
|
-
|
19
11
|
attr_accessor :grid
|
20
|
-
@grid
|
21
|
-
|
22
12
|
attr_accessor :double_markers
|
23
|
-
@double_markers
|
24
|
-
|
25
13
|
attr_accessor :prop_colors
|
26
|
-
@prop_colors
|
27
|
-
|
28
14
|
attr_accessor :zoom
|
29
|
-
@zoom
|
30
|
-
|
31
15
|
attr_accessor :color_set
|
32
|
-
@color_set
|
33
|
-
|
34
16
|
attr_accessor :bookmarks
|
35
|
-
@bookmarks
|
36
|
-
|
37
17
|
attr_accessor :block_fill_pattern
|
38
|
-
@block_fill_pattern
|
39
|
-
|
40
18
|
attr_accessor :block_fill_width
|
41
|
-
@block_fill_width
|
42
|
-
|
43
19
|
attr_accessor :block_fill_height
|
44
|
-
@block_fill_height
|
45
20
|
|
46
21
|
def initialize
|
47
|
-
super GBTiles::GBM::Map::
|
22
|
+
super GBTiles::GBM::Map::OBJECT_TYPE[:map_settings]
|
48
23
|
end
|
49
24
|
|
50
25
|
def self.initFromBitString src
|
@@ -5,19 +5,10 @@ module GBTiles
|
|
5
5
|
class MapTileDataRecord
|
6
6
|
|
7
7
|
attr_accessor :tile_number
|
8
|
-
@tile_number
|
9
|
-
|
10
8
|
attr_accessor :gbc_palette
|
11
|
-
@gbc_palette
|
12
|
-
|
13
9
|
attr_accessor :sgb_palette
|
14
|
-
@sgb_palette
|
15
|
-
|
16
10
|
attr_accessor :flipped_horizontally
|
17
|
-
@flipped_horizontally
|
18
|
-
|
19
11
|
attr_accessor :flipped_vertically
|
20
|
-
@flipped_vertically
|
21
12
|
|
22
13
|
def initialize
|
23
14
|
end
|
@@ -5,19 +5,14 @@ module GBTiles
|
|
5
5
|
class Producer < GBTiles::GBM::Map::Object
|
6
6
|
|
7
7
|
attr_accessor :name
|
8
|
-
@name
|
9
|
-
|
10
8
|
attr_accessor :version
|
11
|
-
@version
|
12
|
-
|
13
9
|
attr_accessor :info
|
14
|
-
@info
|
15
10
|
|
16
11
|
def initialize
|
17
|
-
super GBTiles::GBM::Map::
|
12
|
+
super GBTiles::GBM::Map::OBJECT_TYPE[:producer]
|
18
13
|
end
|
19
14
|
|
20
|
-
def self.initFromBitString
|
15
|
+
def self.initFromBitString src
|
21
16
|
object = GBTiles::GBM::Map::Objects::Producer.new
|
22
17
|
|
23
18
|
object.name = GBTiles::DataType.string!(src, 128)
|
@@ -1,29 +1,12 @@
|
|
1
|
-
require "gbtiles/data_type"
|
2
|
-
|
3
|
-
require "gbtiles/gbr/tile_set/tile_set"
|
4
|
-
require "gbtiles/gbr/tile_set/object"
|
5
|
-
require "gbtiles/gbr/tile_set/object_type"
|
6
|
-
require "gbtiles/gbr/tile_set/split_order"
|
7
|
-
require "gbtiles/gbr/tile_set/color_set"
|
8
|
-
|
9
|
-
require "gbtiles/gbr/tile_set/objects/palettes"
|
10
|
-
require "gbtiles/gbr/tile_set/objects/producer"
|
11
|
-
require "gbtiles/gbr/tile_set/objects/tile_data"
|
12
|
-
require "gbtiles/gbr/tile_set/objects/tile_export"
|
13
|
-
require "gbtiles/gbr/tile_set/objects/tile_import"
|
14
|
-
require "gbtiles/gbr/tile_set/objects/tile_pal"
|
15
|
-
require "gbtiles/gbr/tile_set/objects/tile_settings"
|
16
|
-
require "gbtiles/gbr/tile_set/objects/unknown"
|
17
|
-
|
1
|
+
require "gbtiles/helpers/data_type"
|
18
2
|
require "gbtiles/gbr/import/gbr_file"
|
19
|
-
|
20
3
|
require "gbtiles/gbr/export/asm/asm"
|
21
4
|
|
22
5
|
desc "Convert a file from GBR format"
|
23
6
|
arg_name "input"
|
24
7
|
command :convert do |c|
|
25
8
|
|
26
|
-
c.desc "Output filename
|
9
|
+
c.desc "Output filename [*.s]"
|
27
10
|
c.flag :output
|
28
11
|
|
29
12
|
c.action do |global_options,options,args|
|
@@ -1,22 +1,38 @@
|
|
1
|
+
require "gbtiles/helpers/fixnum"
|
2
|
+
|
3
|
+
require "gbtiles/gbr/tile_set/tile_set"
|
4
|
+
require "gbtiles/gbr/tile_set/object"
|
5
|
+
require "gbtiles/gbr/tile_set/object_type"
|
6
|
+
require "gbtiles/gbr/tile_set/split_order"
|
7
|
+
require "gbtiles/gbr/tile_set/color_set"
|
8
|
+
|
9
|
+
require "gbtiles/gbr/tile_set/objects/palettes"
|
10
|
+
require "gbtiles/gbr/tile_set/objects/producer"
|
11
|
+
require "gbtiles/gbr/tile_set/objects/tile_data"
|
12
|
+
require "gbtiles/gbr/tile_set/objects/tile_export"
|
13
|
+
require "gbtiles/gbr/tile_set/objects/tile_import"
|
14
|
+
require "gbtiles/gbr/tile_set/objects/tile_pal"
|
15
|
+
require "gbtiles/gbr/tile_set/objects/tile_settings"
|
16
|
+
require "gbtiles/gbr/tile_set/objects/unknown"
|
17
|
+
|
1
18
|
module GBTiles
|
2
19
|
module GBR
|
3
20
|
module Import
|
4
21
|
class GBRFile
|
5
|
-
attr_accessor :version, :tile_set
|
6
22
|
|
7
|
-
|
8
|
-
|
23
|
+
attr_accessor :version
|
24
|
+
attr_accessor :tile_set
|
9
25
|
|
10
|
-
def initialize
|
26
|
+
def initialize
|
11
27
|
@tile_set = GBTiles::GBR::TileSet::TileSet.new
|
12
28
|
end
|
13
29
|
|
14
|
-
def self.open
|
30
|
+
def self.open file
|
15
31
|
import = GBTiles::GBR::Import::GBRFile.new
|
16
32
|
|
17
33
|
# Check to see if this is a valid file type
|
18
34
|
if (file.read(3) != "GBO") then
|
19
|
-
raise
|
35
|
+
raise IOError, "Not a valid file (expected: GBO)"
|
20
36
|
end
|
21
37
|
|
22
38
|
# Version number
|
@@ -29,27 +45,27 @@ module GBTiles
|
|
29
45
|
object_len = GBTiles::DataType.long(file.read(4))
|
30
46
|
object_data = file.read(object_len)
|
31
47
|
|
32
|
-
case object_type
|
33
|
-
when
|
34
|
-
object = GBTiles::GBR::TileSet::Objects::Producer.initFromBitString
|
48
|
+
case GBTiles::GBR::TileSet::OBJECT_TYPE.key(object_type)
|
49
|
+
when :producer
|
50
|
+
object = GBTiles::GBR::TileSet::Objects::Producer.initFromBitString(object_data)
|
35
51
|
|
36
|
-
when
|
37
|
-
object = GBTiles::GBR::TileSet::Objects::TileData.initFromBitString
|
52
|
+
when :tile_data
|
53
|
+
object = GBTiles::GBR::TileSet::Objects::TileData.initFromBitString(object_data)
|
38
54
|
|
39
|
-
when
|
40
|
-
object = GBTiles::GBR::TileSet::Objects::TileSettings.initFromBitString
|
55
|
+
when :tile_settings
|
56
|
+
object = GBTiles::GBR::TileSet::Objects::TileSettings.initFromBitString(object_data)
|
41
57
|
|
42
|
-
when
|
43
|
-
object = GBTiles::GBR::TileSet::Objects::TileExport.initFromBitString
|
58
|
+
when :tile_export
|
59
|
+
object = GBTiles::GBR::TileSet::Objects::TileExport.initFromBitString(object_data)
|
44
60
|
|
45
|
-
when
|
46
|
-
object = GBTiles::GBR::TileSet::Objects::TileImport.initFromBitString
|
61
|
+
when :tile_import
|
62
|
+
object = GBTiles::GBR::TileSet::Objects::TileImport.initFromBitString(object_data)
|
47
63
|
|
48
|
-
when
|
49
|
-
object = GBTiles::GBR::TileSet::Objects::Palettes.initFromBitString
|
64
|
+
when :palettes
|
65
|
+
object = GBTiles::GBR::TileSet::Objects::Palettes.initFromBitString(object_data)
|
50
66
|
|
51
|
-
when
|
52
|
-
object = GBTiles::GBR::TileSet::Objects::TilePal.initFromBitString
|
67
|
+
when :tile_pal
|
68
|
+
object = GBTiles::GBR::TileSet::Objects::TilePal.initFromBitString(object_data)
|
53
69
|
|
54
70
|
else
|
55
71
|
object = GBTiles::GBR::TileSet::Objects::Unknown.new object_type
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module GBTiles
|
2
2
|
module GBR
|
3
3
|
module TileSet
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
EXPORT_TYPE = {
|
5
|
+
:rgbds_assembly => 0x00,
|
6
|
+
:rgbds_object => 0x01,
|
7
|
+
:tasm_assembly => 0x02,
|
8
|
+
:gbdk_c => 0x03,
|
9
|
+
:binary => 0x04
|
10
|
+
}
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module GBTiles
|
2
2
|
module GBR
|
3
3
|
module TileSet
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
OBJECT_TYPE = {
|
5
|
+
:producer => 0x01,
|
6
|
+
:tile_data => 0x02,
|
7
|
+
:tile_settings => 0x03,
|
8
|
+
:tile_export => 0x04,
|
9
|
+
:tile_import => 0x05,
|
10
|
+
:palettes => 0x0D,
|
11
|
+
:tile_pal => 0x0E,
|
12
|
+
:deleted => 0xFF
|
13
|
+
}
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,22 +5,13 @@ module GBTiles
|
|
5
5
|
class Palettes < GBTiles::GBR::TileSet::Object
|
6
6
|
|
7
7
|
attr_accessor :id
|
8
|
-
@id
|
9
|
-
|
10
8
|
attr_accessor :count
|
11
|
-
@count
|
12
|
-
|
13
9
|
attr_accessor :colors
|
14
|
-
@colors
|
15
|
-
|
16
10
|
attr_accessor :sgb_count
|
17
|
-
@sgb_count
|
18
|
-
|
19
11
|
attr_accessor :sgb_colors
|
20
|
-
@sgb_colors
|
21
12
|
|
22
13
|
def initialize
|
23
|
-
super GBTiles::GBR::TileSet::
|
14
|
+
super GBTiles::GBR::TileSet::OBJECT_TYPE[:palettes]
|
24
15
|
end
|
25
16
|
|
26
17
|
def self.initFromBitString src
|
@@ -5,16 +5,11 @@ module GBTiles
|
|
5
5
|
class Producer < GBTiles::GBR::TileSet::Object
|
6
6
|
|
7
7
|
attr_accessor :name
|
8
|
-
@name
|
9
|
-
|
10
8
|
attr_accessor :version
|
11
|
-
@version
|
12
|
-
|
13
9
|
attr_accessor :info
|
14
|
-
@info
|
15
10
|
|
16
11
|
def initialize
|
17
|
-
super GBTiles::GBR::TileSet::
|
12
|
+
super GBTiles::GBR::TileSet::OBJECT_TYPE[:producer]
|
18
13
|
end
|
19
14
|
|
20
15
|
def self.initFromBitString src
|
@@ -5,25 +5,14 @@ module GBTiles
|
|
5
5
|
class TileData < GBTiles::GBR::TileSet::Object
|
6
6
|
|
7
7
|
attr_accessor :name
|
8
|
-
@name
|
9
|
-
|
10
8
|
attr_accessor :width
|
11
|
-
@width
|
12
|
-
|
13
9
|
attr_accessor :height
|
14
|
-
@height
|
15
|
-
|
16
10
|
attr_accessor :count
|
17
|
-
@count
|
18
|
-
|
19
11
|
attr_accessor :color_set
|
20
|
-
@color_set
|
21
|
-
|
22
12
|
attr_accessor :data
|
23
|
-
@data
|
24
13
|
|
25
14
|
def initialize
|
26
|
-
super GBTiles::GBR::TileSet::
|
15
|
+
super GBTiles::GBR::TileSet::OBJECT_TYPE[:tile_data]
|
27
16
|
end
|
28
17
|
|
29
18
|
def self.initFromBitString src
|
@@ -39,7 +28,7 @@ module GBTiles
|
|
39
28
|
object
|
40
29
|
end
|
41
30
|
|
42
|
-
def render_tile
|
31
|
+
def render_tile tile_index
|
43
32
|
tile = []
|
44
33
|
|
45
34
|
tile_data = @data.slice(
|
@@ -5,70 +5,29 @@ module GBTiles
|
|
5
5
|
class TileExport < GBTiles::GBR::TileSet::Object
|
6
6
|
|
7
7
|
attr_accessor :tile_id
|
8
|
-
@tile_id
|
9
|
-
|
10
8
|
attr_accessor :file_name
|
11
|
-
@file_name
|
12
|
-
|
13
9
|
attr_accessor :file_type
|
14
|
-
@file_type
|
15
|
-
|
16
10
|
attr_accessor :section_name
|
17
|
-
@section_name
|
18
|
-
|
19
11
|
attr_accessor :label_name
|
20
|
-
@label_name
|
21
|
-
|
22
12
|
attr_accessor :bank
|
23
|
-
@bank
|
24
|
-
|
25
13
|
attr_accessor :tile_array
|
26
|
-
@tile_array
|
27
|
-
|
28
14
|
attr_accessor :format
|
29
|
-
@format
|
30
|
-
|
31
15
|
attr_accessor :counter
|
32
|
-
@counter
|
33
|
-
|
34
16
|
attr_accessor :from
|
35
|
-
@from
|
36
|
-
|
37
17
|
attr_accessor :upto
|
38
|
-
@upto
|
39
|
-
|
40
18
|
attr_accessor :compression
|
41
|
-
@compression
|
42
|
-
|
43
19
|
attr_accessor :include_colors
|
44
|
-
@include_colors
|
45
|
-
|
46
20
|
attr_accessor :sgb_palettes
|
47
|
-
@sgb_palettes
|
48
|
-
|
49
21
|
attr_accessor :gbc_palettes
|
50
|
-
@gbc_palettes
|
51
|
-
|
52
22
|
attr_accessor :make_meta_tiles
|
53
|
-
@make_meta_tiles
|
54
|
-
|
55
23
|
attr_accessor :meta_offset
|
56
|
-
@meta_offset
|
57
|
-
|
58
24
|
attr_accessor :meta_counter
|
59
|
-
@meta_counter
|
60
|
-
|
61
25
|
attr_accessor :split
|
62
|
-
@split
|
63
|
-
|
64
26
|
attr_accessor :block_size
|
65
|
-
@block_size
|
66
|
-
|
67
27
|
attr_accessor :sel_tab
|
68
|
-
@sel_tab
|
69
28
|
|
70
29
|
def initialize
|
71
|
-
super GBTiles::GBR::TileSet::
|
30
|
+
super GBTiles::GBR::TileSet::OBJECT_TYPE[:tile_export]
|
72
31
|
end
|
73
32
|
|
74
33
|
def self.initFromBitString src
|