retrograph_easy 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +19 -0
- data/README +13 -0
- data/Rakefile +64 -0
- data/demos/defense.rb +413 -0
- data/demos/logo.rb +34 -0
- data/lib/retrograph/easy/app.rb +257 -0
- data/lib/retrograph/easy/constants.rb +35 -0
- data/lib/retrograph/easy/controllers.rb +184 -0
- data/lib/retrograph/easy/display.rb +173 -0
- data/lib/retrograph/easy/logo.rb +287 -0
- data/lib/retrograph/easy/periodic.rb +99 -0
- data/lib/retrograph/easy/sprites.rb +133 -0
- data/lib/retrograph/easy.rb +32 -0
- data/lib/retrograph/sdl.rb +26 -0
- data/lib/retrograph.rb +29 -0
- data/spec/easy_spec.rb +6 -0
- metadata +83 -0
@@ -0,0 +1,287 @@
|
|
1
|
+
# retrograph/easy/logo - the retrograph logo display magic
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 MenTaLguY <mental@rydia.net>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
module Retrograph
|
25
|
+
module Easy
|
26
|
+
|
27
|
+
class Logo
|
28
|
+
def initialize(app)
|
29
|
+
@app = app
|
30
|
+
end
|
31
|
+
|
32
|
+
def show
|
33
|
+
@app.reset_vdu
|
34
|
+
|
35
|
+
@app.vdu_mode 0x7
|
36
|
+
|
37
|
+
# setup palette
|
38
|
+
@app.palette_entry_rgb 0, 0, 0, 0
|
39
|
+
@app.palette_entry_rgb 1, 255, 0, 0
|
40
|
+
|
41
|
+
# setup patterns
|
42
|
+
@app.tile_pattern_4bit(0x0000, START_PATTERN, PATTERN_DATA)
|
43
|
+
|
44
|
+
num_characters = CHARACTERS.size
|
45
|
+
|
46
|
+
start_row = (28 - 4) / 2 - 2
|
47
|
+
start_col = (32 - (num_characters * 2)) / 2
|
48
|
+
name_base = (start_col + start_row * 32) * 2
|
49
|
+
|
50
|
+
# setup name table
|
51
|
+
@app.write_vdu(0x0800 + name_base, LETTER_NAME_DATA)
|
52
|
+
name_base += 64
|
53
|
+
prepare_led_characters(name_base, num_characters)
|
54
|
+
|
55
|
+
# start display loop
|
56
|
+
characters = [0] * num_characters
|
57
|
+
delay = 9
|
58
|
+
for revealed in 0..num_characters
|
59
|
+
@app.each_of_n_frames(delay) do
|
60
|
+
characters.map! { rand(127) + 1 }
|
61
|
+
characters[0, revealed] = CHARACTERS[0, revealed]
|
62
|
+
show_led_characters(name_base, characters)
|
63
|
+
end
|
64
|
+
delay = 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def prepare_led_characters(name_base, count)
|
69
|
+
count.times do
|
70
|
+
prepare_led_character(name_base)
|
71
|
+
name_base += 4
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def prepare_led_character(name_base)
|
76
|
+
@app.write_vdu_byte(0x0800 + name_base + 3, 0b00100000)
|
77
|
+
@app.write_vdu_byte(0x0800 + name_base + 67, 0b00100000)
|
78
|
+
@app.write_vdu_byte(0x0800 + name_base + 129, 0b00010000)
|
79
|
+
@app.write_vdu_byte(0x0800 + name_base + 131, 0b00110000)
|
80
|
+
end
|
81
|
+
|
82
|
+
def show_led_characters(name_base, cs)
|
83
|
+
cs.each do |c|
|
84
|
+
show_led_character(name_base, c)
|
85
|
+
name_base += 4
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def show_led_character(name_base, c)
|
90
|
+
for (name_offset, index, mappings) in CHAR_BIT_MAPPINGS
|
91
|
+
for (mask, shift) in mappings
|
92
|
+
index += (c & mask) >> shift
|
93
|
+
end
|
94
|
+
@app.write_vdu_byte(0x0800 + name_base + name_offset, index)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
Logo::START_PATTERN = 1
|
100
|
+
|
101
|
+
ma_pattern = [
|
102
|
+
0x00000000,
|
103
|
+
0x01001010,
|
104
|
+
0x10101110,
|
105
|
+
0x11101110,
|
106
|
+
0x10101010,
|
107
|
+
0x10101010,
|
108
|
+
0x00000000,
|
109
|
+
0x00000000
|
110
|
+
].pack("V8")
|
111
|
+
|
112
|
+
de_pattern = [
|
113
|
+
0x00000000,
|
114
|
+
0x11100110,
|
115
|
+
0x00101010,
|
116
|
+
0x01101010,
|
117
|
+
0x00101010,
|
118
|
+
0x11100110,
|
119
|
+
0x00000000,
|
120
|
+
0x00000000
|
121
|
+
].pack("V8")
|
122
|
+
|
123
|
+
wi_pattern = [
|
124
|
+
0x00000000,
|
125
|
+
0x10101000,
|
126
|
+
0x10101000,
|
127
|
+
0x10101000,
|
128
|
+
0x10111000,
|
129
|
+
0x10111000,
|
130
|
+
0x00000000,
|
131
|
+
0x00000000
|
132
|
+
].pack("V8")
|
133
|
+
|
134
|
+
th_pattern = [
|
135
|
+
0x00000000,
|
136
|
+
0x10101110,
|
137
|
+
0x10100100,
|
138
|
+
0x11100100,
|
139
|
+
0x10100100,
|
140
|
+
0x10100100,
|
141
|
+
0x00000000,
|
142
|
+
0x00000000
|
143
|
+
].pack("V8")
|
144
|
+
|
145
|
+
letter_patterns = [
|
146
|
+
ma_pattern,
|
147
|
+
de_pattern,
|
148
|
+
wi_pattern,
|
149
|
+
th_pattern
|
150
|
+
]
|
151
|
+
|
152
|
+
letter_pattern_offset = Logo::START_PATTERN
|
153
|
+
n_letter_patterns = letter_patterns.size
|
154
|
+
|
155
|
+
blank = [
|
156
|
+
0x00000000,
|
157
|
+
0x00000000,
|
158
|
+
0x00000000,
|
159
|
+
0x00000000,
|
160
|
+
0x00000000,
|
161
|
+
0x00000000,
|
162
|
+
0x00000000,
|
163
|
+
0x00000000
|
164
|
+
]
|
165
|
+
|
166
|
+
corner_horizontal = [
|
167
|
+
0x00000000,
|
168
|
+
0x11111000,
|
169
|
+
0x11110000,
|
170
|
+
0x11100000,
|
171
|
+
0x00000000,
|
172
|
+
0x00000000,
|
173
|
+
0x00000000,
|
174
|
+
0x00000000
|
175
|
+
]
|
176
|
+
|
177
|
+
corner_vertical = [
|
178
|
+
0x00000000,
|
179
|
+
0x00000000,
|
180
|
+
0x00000010,
|
181
|
+
0x00000110,
|
182
|
+
0x00001110,
|
183
|
+
0x00001110,
|
184
|
+
0x00001110,
|
185
|
+
0x00001110
|
186
|
+
]
|
187
|
+
|
188
|
+
raw_corner_images = [
|
189
|
+
corner_vertical,
|
190
|
+
corner_horizontal
|
191
|
+
]
|
192
|
+
|
193
|
+
corner_pattern_offset = letter_pattern_offset + n_letter_patterns
|
194
|
+
n_corner_patterns = 1 << raw_corner_images.size
|
195
|
+
|
196
|
+
middle_horizontal = [
|
197
|
+
0x00000000,
|
198
|
+
0x00000000,
|
199
|
+
0x11110000,
|
200
|
+
0x11111000,
|
201
|
+
0x11110000,
|
202
|
+
0x00000000,
|
203
|
+
0x00000000,
|
204
|
+
0x00000000
|
205
|
+
]
|
206
|
+
|
207
|
+
middle_vertical_top = [
|
208
|
+
0x00001110,
|
209
|
+
0x00000110,
|
210
|
+
0x00000010,
|
211
|
+
0x00000000,
|
212
|
+
0x00000000,
|
213
|
+
0x00000000,
|
214
|
+
0x00000000,
|
215
|
+
0x00000000
|
216
|
+
]
|
217
|
+
|
218
|
+
middle_vertical_bottom = [
|
219
|
+
0x00000000,
|
220
|
+
0x00000000,
|
221
|
+
0x00000000,
|
222
|
+
0x00000000,
|
223
|
+
0x00000010,
|
224
|
+
0x00000110,
|
225
|
+
0x00001110,
|
226
|
+
0x00001110
|
227
|
+
]
|
228
|
+
|
229
|
+
raw_middle_images = [
|
230
|
+
middle_vertical_bottom,
|
231
|
+
middle_vertical_top,
|
232
|
+
middle_horizontal
|
233
|
+
]
|
234
|
+
|
235
|
+
middle_pattern_offset = corner_pattern_offset + n_corner_patterns
|
236
|
+
n_middle_patterns = 1 << raw_middle_images.size
|
237
|
+
|
238
|
+
Logo::LETTER_NAME_DATA = (0...n_letter_patterns).map { |i|
|
239
|
+
[ i + letter_pattern_offset, 0 ]
|
240
|
+
}.flatten.pack("C*")
|
241
|
+
|
242
|
+
led_patterns = [raw_corner_images, raw_middle_images].map { |raw_images|
|
243
|
+
bits = raw_images.size
|
244
|
+
(0...(1 << bits)).map { |i|
|
245
|
+
image = blank
|
246
|
+
for bit in 0...bits
|
247
|
+
if ((i >> bit) & 1).nonzero?
|
248
|
+
image = image.zip(raw_images[bit]).map { |a, b| a | b }
|
249
|
+
end
|
250
|
+
end
|
251
|
+
image.pack("V8")
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
Logo::PATTERN_DATA = [letter_patterns, led_patterns].flatten.inject("") { |a, b| a + b }
|
256
|
+
|
257
|
+
Logo::CHARACTERS = [
|
258
|
+
0b00100010, # r
|
259
|
+
0b01111110, # e
|
260
|
+
0b00111010, # t
|
261
|
+
0b00100010, # r
|
262
|
+
0b00110011, # o
|
263
|
+
0b01111101, # g
|
264
|
+
0b00100010, # r
|
265
|
+
0b01110111, # a
|
266
|
+
0b01101110, # P
|
267
|
+
0b00101011 # h
|
268
|
+
]
|
269
|
+
|
270
|
+
Logo::CHAR_BIT_MAPPINGS = [
|
271
|
+
[0, corner_pattern_offset, [[0b01000000, 5], [0b00001000, 3]]],
|
272
|
+
[2, corner_pattern_offset, [[0b01000000, 5], [0b00000100, 2]]],
|
273
|
+
[64, middle_pattern_offset, [[0b00100000, 3], [0b00001000, 2], [0b00000010, 1]]],
|
274
|
+
[66, middle_pattern_offset, [[0b00100000, 3], [0b00000100, 1], [0b00000001, 0]]],
|
275
|
+
[128, corner_pattern_offset, [[0b00010000, 3], [0b00000010, 1]]],
|
276
|
+
[130, corner_pattern_offset, [[0b00010000, 3], [0b00000001, 0]]]
|
277
|
+
]
|
278
|
+
|
279
|
+
class App
|
280
|
+
def show_retrograph_logo
|
281
|
+
Logo.new(self).show
|
282
|
+
self
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# retrograph/easy/periodic
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 MenTaLguY <mental@rydia.net>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
module Retrograph
|
25
|
+
module Easy
|
26
|
+
|
27
|
+
class Periodic
|
28
|
+
def initialize(interval, phases)
|
29
|
+
@count = 0
|
30
|
+
@interval = interval.to_i
|
31
|
+
@period = @interval * phases.to_i
|
32
|
+
end
|
33
|
+
|
34
|
+
def phase
|
35
|
+
@count / @interval
|
36
|
+
end
|
37
|
+
|
38
|
+
def firing?
|
39
|
+
(@count % @interval).zero?
|
40
|
+
end
|
41
|
+
|
42
|
+
def tick
|
43
|
+
@count = (@count + 1) % @period
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class PeriodicManager
|
49
|
+
def initialize
|
50
|
+
@named_periodics = {}
|
51
|
+
end
|
52
|
+
|
53
|
+
def start(label, interval, phases)
|
54
|
+
label = label.to_sym
|
55
|
+
periodic = Periodic.new(interval, phases)
|
56
|
+
@named_periodics[label] = periodic
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def stop(label)
|
61
|
+
label = label.to_sym
|
62
|
+
@named_periodics.delete label
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def frame_for?(label)
|
67
|
+
label = label.to_sym
|
68
|
+
begin
|
69
|
+
periodic = @named_periodics.fetch label
|
70
|
+
rescue IndexError
|
71
|
+
return false
|
72
|
+
end
|
73
|
+
periodic.firing?
|
74
|
+
end
|
75
|
+
|
76
|
+
def already?(label)
|
77
|
+
label = label.to_sym
|
78
|
+
@named_periodics.has_key? label
|
79
|
+
end
|
80
|
+
|
81
|
+
def phase_of(label)
|
82
|
+
label = label.to_sym
|
83
|
+
begin
|
84
|
+
periodic = @named_periodics.fetch label
|
85
|
+
rescue IndexError
|
86
|
+
return 0
|
87
|
+
end
|
88
|
+
periodic.phase
|
89
|
+
end
|
90
|
+
|
91
|
+
def tick
|
92
|
+
@named_periodics.each_value do |periodic|
|
93
|
+
periodic.tick
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# retrograph/easy/sprites
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 MenTaLguY <mental@rydia.net>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
class String
|
25
|
+
if instance_methods.include? :get_byte # 1.9
|
26
|
+
alias_method :_retrograph_get_byte, :get_byte
|
27
|
+
else
|
28
|
+
alias_method :_retrograph_get_byte, :[]
|
29
|
+
end
|
30
|
+
if instance_methods.include? :set_byte # 1.9
|
31
|
+
alias_method :_retrograph_set_byte, :set_byte
|
32
|
+
else
|
33
|
+
alias_method :_retrograph_set_byte, :[]=
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Retrograph
|
38
|
+
module Easy
|
39
|
+
|
40
|
+
class SpriteManager
|
41
|
+
BLANK_SPRITES = ("\000" * 256).freeze
|
42
|
+
|
43
|
+
def initialize(display)
|
44
|
+
@display = display
|
45
|
+
@sprite_data = "\000" * 4
|
46
|
+
@data_offset = 0
|
47
|
+
@flip_flags = 0
|
48
|
+
@other_flags = 0
|
49
|
+
@x_exp = 0
|
50
|
+
@y_exp = 0
|
51
|
+
@x = 0
|
52
|
+
@y = 0
|
53
|
+
@mirror_x = 0
|
54
|
+
@mirror_y = 0
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_sprite_group(x, y, width, height, flags)
|
58
|
+
saved_flip_flags = @flip_flags
|
59
|
+
saved_other_flags = @other_flags
|
60
|
+
saved_x_exp = @x_exp
|
61
|
+
saved_y_exp = @y_exp
|
62
|
+
saved_x = @x
|
63
|
+
saved_y = @y
|
64
|
+
saved_mirror_x = @mirror_x
|
65
|
+
saved_mirror_y = @mirror_y
|
66
|
+
begin
|
67
|
+
x = @mirror_x - x if (@flip_flags & 0b00100000).nonzero?
|
68
|
+
y = @mirror_y - y if (@flip_flags & 0b00010000).nonzero?
|
69
|
+
@x = (x << @x_exp) + @x
|
70
|
+
@y = (y << @y_exp) + @y
|
71
|
+
@flip_flags ^= flags & 0b00110000
|
72
|
+
@other_flags |= flags & 0b00001111
|
73
|
+
@x_exp = (@flip_flags & 0b00001000) >> 3
|
74
|
+
@y_exp = (@flip_flags & 0b00000100) >> 2
|
75
|
+
@mirror_x = (width << @x_exp) - (8 << @x_exp)
|
76
|
+
@mirror_y = (height << @y_exp) - (8 << @y_exp)
|
77
|
+
yield
|
78
|
+
rescue
|
79
|
+
@flip_flags = saved_flip_flags
|
80
|
+
@other_flags = saved_other_flags
|
81
|
+
@x_exp = saved_x_exp
|
82
|
+
@y_exp = saved_y_exp
|
83
|
+
@x = saved_x
|
84
|
+
@y = saved_y
|
85
|
+
@mirror_x = saved_mirror_x
|
86
|
+
@mirror_y = saved_mirror_y
|
87
|
+
end
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_multi_sprite(x, y, pattern, width_tiles, height_tiles, flags)
|
92
|
+
add_sprite_group(x, y, width_tiles << 3, height_tiles << 3, flags) do
|
93
|
+
row = 0
|
94
|
+
while row < height_tiles
|
95
|
+
col = 0
|
96
|
+
while col < width_tiles
|
97
|
+
add_sprite(x + (col << 3), y + (row << 3), (pattern + col) & 0xff, 0)
|
98
|
+
col += 1
|
99
|
+
end
|
100
|
+
pattern += 32
|
101
|
+
row += 1
|
102
|
+
end
|
103
|
+
end
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
|
107
|
+
def add_sprite(x, y, pattern, flags)
|
108
|
+
return nil unless @data_offset < 256
|
109
|
+
x = @mirror_x - x if (@flip_flags & 0b00100000).nonzero?
|
110
|
+
y = @mirror_y - y if (@flip_flags & 0b00010000).nonzero?
|
111
|
+
x = (x << @x_exp) + @x
|
112
|
+
y = (y << @y_exp) + @y
|
113
|
+
if x >= 0 and x < 256 and y >= 0 and y < 224
|
114
|
+
flags = (flags ^ @flip_flags) | @other_flags
|
115
|
+
@sprite_data._retrograph_set_byte(0, x)
|
116
|
+
@sprite_data._retrograph_set_byte(1, y + 1)
|
117
|
+
@sprite_data._retrograph_set_byte(2, pattern)
|
118
|
+
@sprite_data._retrograph_set_byte(3, flags)
|
119
|
+
@display.write_vdu(0x7e00 + @data_offset, @sprite_data)
|
120
|
+
end
|
121
|
+
@data_offset += 4
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def clear_sprites
|
126
|
+
@display.write_vdu(0x7e00, BLANK_SPRITES)
|
127
|
+
@data_offset = 0
|
128
|
+
self
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# retrograph/easy
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 MenTaLguY <mental@rydia.net>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'retrograph/easy/constants'
|
25
|
+
require 'retrograph/easy/app'
|
26
|
+
require 'retrograph/easy/logo'
|
27
|
+
|
28
|
+
def Retrograph.app(&block)
|
29
|
+
Retrograph::Easy.app do
|
30
|
+
self.instance_eval(&block)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# retrograph/sdl
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 MenTaLguY <mental@rydia.net>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'retrograph'
|
24
|
+
require 'sdl'
|
25
|
+
|
26
|
+
Retrograph._init_sdl
|
data/lib/retrograph.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# retrograph
|
2
|
+
#
|
3
|
+
# Copyright (c) 2009 MenTaLguY <mental@rydia.net>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
# augment search path for fat binary gems
|
25
|
+
ruby_version = /^\d+\.\d+/.match(RUBY_VERSION)[0]
|
26
|
+
base_dir = File.dirname(__FILE__)
|
27
|
+
$:.push File.join(base_dir, ruby_version)
|
28
|
+
|
29
|
+
require 'retrograph.so'
|
data/spec/easy_spec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: retrograph_easy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MenTaLguY <mental@rydia.net>
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-24 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: retrograph
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0.5"
|
24
|
+
version:
|
25
|
+
description: |
|
26
|
+
Retrograph/EASY is a simple API built atop Retrograph, a software renderer
|
27
|
+
which simulates a late-era 8-bit display with capabilities similar to those
|
28
|
+
of the Sega Master System.
|
29
|
+
|
30
|
+
email: mental@rydia.net
|
31
|
+
executables: []
|
32
|
+
|
33
|
+
extensions: []
|
34
|
+
|
35
|
+
extra_rdoc_files: []
|
36
|
+
|
37
|
+
files:
|
38
|
+
- Rakefile
|
39
|
+
- README
|
40
|
+
- COPYING
|
41
|
+
- lib/retrograph.rb
|
42
|
+
- lib/retrograph/easy.rb
|
43
|
+
- lib/retrograph/sdl.rb
|
44
|
+
- lib/retrograph/easy/app.rb
|
45
|
+
- lib/retrograph/easy/logo.rb
|
46
|
+
- lib/retrograph/easy/constants.rb
|
47
|
+
- lib/retrograph/easy/display.rb
|
48
|
+
- lib/retrograph/easy/controllers.rb
|
49
|
+
- lib/retrograph/easy/sprites.rb
|
50
|
+
- lib/retrograph/easy/periodic.rb
|
51
|
+
- spec/easy_spec.rb
|
52
|
+
- demos/defense.rb
|
53
|
+
- demos/logo.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://rubyforge.org/projects/retrograph
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: retrograph
|
78
|
+
rubygems_version: 1.3.4
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Retrograph/EASY, a simple API for Retrograph games.
|
82
|
+
test_files: []
|
83
|
+
|