img_to_script 1.0.0 → 1.1.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/CHANGELOG.md +14 -0
- data/README.md +10 -2
- data/lib/img_to_script/generators/hex_mask/enhanced.rb +0 -9
- data/lib/img_to_script/generators/hex_mask/forced_point_move.rb +54 -0
- data/lib/img_to_script/generators/hex_mask/hex_mask.rb +9 -0
- data/lib/img_to_script/generators/run_length_encoding/run_length_encoding.rb +2 -2
- data/lib/img_to_script/languages/mk90_basic/translators/mixin.rb +0 -13
- data/lib/img_to_script/languages/mk90_basic/translators/mk90_basic_10.rb +14 -0
- data/lib/img_to_script/languages/mk90_basic/translators/mk90_basic_20.rb +15 -0
- data/lib/img_to_script/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c994729915516c1b890ec338d85867ac2e8071d442f934c00f512645dbc42fa8
|
4
|
+
data.tar.gz: 9e396865898b8f4bb1644b9120b60163aa850d2e84118959f3a2e21fb914b982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d200b4b5f8494e54096941652285689e6bb27f85217381f260b37992dacf02fc428d1d8a902083497701d014739cc7f74435893e91f9afb03121bc524aa14d00
|
7
|
+
data.tar.gz: bbba0740ea201d70e330bcac059ae9f6904488585f9794e5e66b8f6b02d444cce053b2dfff6e8e6625c0decd70856e7298e57b8cc6d6d5e1154f642c360b9ecb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [1.1.0] - 2024-01-26
|
2
|
+
|
3
|
+
- New generator: `HexMask::ForcedPointMove`.
|
4
|
+
|
5
|
+
Due to a found bug in the MK90 BASIC v.2.0, hex-mask based generators won't work on this systems. This generator is a workaround that should be used to generate scripts for the v.2.0 systems.
|
6
|
+
|
7
|
+
- Improved MK90 BASIC v.2.0 compatibility
|
8
|
+
|
9
|
+
Due to yet another found bug in the MK90 BASIC v.2.0, the DRAW O statement won't work on this systems. The update introduces a workaround for this bug.
|
10
|
+
|
11
|
+
## [1.0.1] - 2023-12-29
|
12
|
+
|
13
|
+
- Bug fix.
|
14
|
+
|
1
15
|
## [1.0.0] - 2023-12-11
|
2
16
|
|
3
17
|
- API change.
|
data/README.md
CHANGED
@@ -172,20 +172,28 @@ script = task.run(
|
|
172
172
|
|
173
173
|
- **ImgToScript::Generators::HexMask::Default**
|
174
174
|
|
175
|
-
Specific for the Elektronika MK90 BASIC.
|
175
|
+
Specific for the Elektronika MK90 BASIC v.1.0 **only**.
|
176
176
|
|
177
177
|
MK90's BASIC has a balanced build-in method to encode and render images. The Elektronika MK90's manual refers to it as the *hex-mask rendering* method. Each 8x1 px block of a binary image is being represented as a hex value (e.g. '00' for a tile of the 8 white pixels in a row, 'FF' for a tile of the 8 black pixels in a row, etc.). Then these hex values are being passed as arguments to the DRAM/M BASIC statement that renders the image according to the provided data.
|
178
178
|
|
179
179
|
Due to the logic of the DRAM/M operator, only vertical scan lines are supported.
|
180
180
|
|
181
|
+
**Note**: due to a bug in the MK90 BASIC v.2.0 software, this generation method works only on the BASIC v.1.0 systems.
|
182
|
+
|
183
|
+
- **ImgToScript::Generators::HexMask::ForcedPointMove**
|
184
|
+
|
185
|
+
Same as `HexMask::Default`, but with a workaround for the MK90 BASIC v.2.0.
|
186
|
+
|
181
187
|
- **ImgToScript::Generators::HexMask::Enhanced**
|
182
188
|
|
183
|
-
Specific for the Elektronika MK90 BASIC.
|
189
|
+
Specific for the Elektronika MK90 BASIC v.1.0 **only**.
|
184
190
|
|
185
191
|
Hex-mask encoding with modifications what make output BASIC code more compact.
|
186
192
|
|
187
193
|
Due to the logic of the DRAM/M operator, only vertical scan lines are supported.
|
188
194
|
|
195
|
+
**Note**: due to a bug in the MK90 BASIC v.2.0 software, this generation method works only on the BASIC v.1.0 systems.
|
196
|
+
|
189
197
|
- **ImgToScript::Generators::RunLengthEncoding::Horizontal**
|
190
198
|
|
191
199
|
RLE, horizontal scan lines.
|
@@ -162,15 +162,6 @@ module ImgToScript
|
|
162
162
|
)
|
163
163
|
end
|
164
164
|
|
165
|
-
def _append_move_point(x, y)
|
166
|
-
@tokens.append(
|
167
|
-
AbstractToken::MovePointToAbsCoords.new(
|
168
|
-
x: x,
|
169
|
-
y: y
|
170
|
-
)
|
171
|
-
)
|
172
|
-
end
|
173
|
-
|
174
165
|
#
|
175
166
|
# Replace long sequences of white chunks (0x00) with a shorter manual shift of the (X, Y) point.
|
176
167
|
#
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ImgToScript
|
4
|
+
module Generators
|
5
|
+
module HexMask
|
6
|
+
#
|
7
|
+
# Workaround for the MK90 BASIC v.2.0.
|
8
|
+
#
|
9
|
+
class ForcedPointMove < HexMask
|
10
|
+
SEG_CHUNK_LENGTH = 28
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def _generate
|
15
|
+
_process_seg_chunks(
|
16
|
+
_encode_img.each_slice(SEG_CHUNK_LENGTH).to_a
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def _process_seg_chunks(seg_chunks)
|
21
|
+
x = 0
|
22
|
+
y = 0
|
23
|
+
|
24
|
+
seg_chunks.each do |chunk|
|
25
|
+
# Append only non-white segments:
|
26
|
+
_append_hex_values(chunk) unless _all_elements_equal?(chunk, "00")
|
27
|
+
|
28
|
+
if y + SEG_CHUNK_LENGTH > @scr_height - 1
|
29
|
+
y = (y + SEG_CHUNK_LENGTH) - @scr_height
|
30
|
+
x += CHUNK_WIDTH
|
31
|
+
else
|
32
|
+
y += SEG_CHUNK_LENGTH
|
33
|
+
end
|
34
|
+
|
35
|
+
_append_move_point(x, y)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def _all_elements_equal?(array, value)
|
40
|
+
array.all? { |element| element == value }
|
41
|
+
end
|
42
|
+
|
43
|
+
def _append_hex_values(hex_values)
|
44
|
+
@tokens.append(
|
45
|
+
AbstractToken::DrawChunkByHexValue.new(
|
46
|
+
hex_values: hex_values,
|
47
|
+
require_nl: true
|
48
|
+
)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -70,7 +70,7 @@ module ImgToScript
|
|
70
70
|
#
|
71
71
|
# The IF statement is used to check cases where the line would extend
|
72
72
|
# beyond the bounds of the image/screen. In this case the program jumps
|
73
|
-
# to the 5-th line (
|
73
|
+
# to the 5-th line (4 lines down from the current line) of the decoder,
|
74
74
|
# that handles this edge case.
|
75
75
|
#
|
76
76
|
def _dec_line02
|
@@ -82,7 +82,7 @@ module ImgToScript
|
|
82
82
|
@tokens.append(
|
83
83
|
AbstractToken::IfCondition.new(
|
84
84
|
expression: expression,
|
85
|
-
consequent: CurrentLinePlaceholder.new(
|
85
|
+
consequent: CurrentLinePlaceholder.new(4),
|
86
86
|
require_nl: true
|
87
87
|
)
|
88
88
|
)
|
@@ -96,19 +96,6 @@ module ImgToScript
|
|
96
96
|
_math_operation(token, "*")
|
97
97
|
end
|
98
98
|
|
99
|
-
def _move_point_to_abs_coords(token)
|
100
|
-
MK90BasicToken.new(
|
101
|
-
keyword: "DRAWO",
|
102
|
-
args: _translate_arguments([
|
103
|
-
token.x,
|
104
|
-
token.y
|
105
|
-
]),
|
106
|
-
separator: ",",
|
107
|
-
require_nl: token.require_nl,
|
108
|
-
sliceable: false
|
109
|
-
)
|
110
|
-
end
|
111
|
-
|
112
99
|
def _go_to(token)
|
113
100
|
MK90BasicToken.new(
|
114
101
|
keyword: "GOTO",
|
@@ -20,6 +20,20 @@ module ImgToScript
|
|
20
20
|
sliceable: false
|
21
21
|
)
|
22
22
|
end
|
23
|
+
|
24
|
+
# MK90 BASIC v.1.0 does support the DRAW O statement.
|
25
|
+
def _move_point_to_abs_coords(token)
|
26
|
+
MK90BasicToken.new(
|
27
|
+
keyword: "DRAWO",
|
28
|
+
args: _translate_arguments([
|
29
|
+
token.x,
|
30
|
+
token.y
|
31
|
+
]),
|
32
|
+
separator: ",",
|
33
|
+
require_nl: token.require_nl,
|
34
|
+
sliceable: false
|
35
|
+
)
|
36
|
+
end
|
23
37
|
end
|
24
38
|
end
|
25
39
|
end
|
@@ -20,6 +20,21 @@ module ImgToScript
|
|
20
20
|
sliceable: false
|
21
21
|
)
|
22
22
|
end
|
23
|
+
|
24
|
+
# MK90 BASIC v.2.0 does NOT support the DRAW O statement due to a bug,
|
25
|
+
# the LOCATE statement should be used instead.
|
26
|
+
def _move_point_to_abs_coords(token)
|
27
|
+
MK90BasicToken.new(
|
28
|
+
keyword: "LOCATE",
|
29
|
+
args: _translate_arguments([
|
30
|
+
token.x,
|
31
|
+
token.y
|
32
|
+
]),
|
33
|
+
separator: ",",
|
34
|
+
require_nl: token.require_nl,
|
35
|
+
sliceable: false
|
36
|
+
)
|
37
|
+
end
|
23
38
|
end
|
24
39
|
end
|
25
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: img_to_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 8bit-mate
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-system
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/img_to_script/generators/hex_mask.rb
|
140
140
|
- lib/img_to_script/generators/hex_mask/default.rb
|
141
141
|
- lib/img_to_script/generators/hex_mask/enhanced.rb
|
142
|
+
- lib/img_to_script/generators/hex_mask/forced_point_move.rb
|
142
143
|
- lib/img_to_script/generators/hex_mask/hex_mask.rb
|
143
144
|
- lib/img_to_script/generators/run_length_encoding.rb
|
144
145
|
- lib/img_to_script/generators/run_length_encoding/horizontal.rb
|