cyross-ruby-miyako 2.0.5.1 → 2.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.
- data/README +1092 -929
- data/Rakefile +7 -7
- data/defines.h +144 -144
- data/extern.h +29 -29
- data/install_miyako.rb +87 -87
- data/lib/Miyako/API/audio.rb +572 -198
- data/lib/Miyako/API/basic_data.rb +825 -573
- data/lib/Miyako/API/bitmap.rb +534 -507
- data/lib/Miyako/API/choices.rb +481 -475
- data/lib/Miyako/API/collision.rb +486 -460
- data/lib/Miyako/API/diagram.rb +586 -561
- data/lib/Miyako/API/drawing.rb +151 -151
- data/lib/Miyako/API/exceptions.rb +105 -0
- data/lib/Miyako/API/fixedmap.rb +462 -428
- data/lib/Miyako/API/font.rb +430 -403
- data/lib/Miyako/API/input.rb +456 -447
- data/lib/Miyako/API/layout.rb +636 -433
- data/lib/Miyako/API/map.rb +583 -529
- data/lib/Miyako/API/map_event.rb +222 -198
- data/lib/Miyako/API/modules.rb +357 -109
- data/lib/Miyako/API/movie.rb +166 -154
- data/lib/Miyako/API/parts.rb +276 -189
- data/lib/Miyako/API/plane.rb +205 -166
- data/lib/Miyako/API/screen.rb +341 -325
- data/lib/Miyako/API/shape.rb +443 -443
- data/lib/Miyako/API/sprite.rb +771 -752
- data/lib/Miyako/API/sprite_animation.rb +490 -481
- data/lib/Miyako/API/sprite_list.rb +1135 -0
- data/lib/Miyako/API/spriteunit.rb +168 -147
- data/lib/Miyako/API/story.rb +350 -300
- data/lib/Miyako/API/textbox.rb +770 -725
- data/lib/Miyako/API/utility.rb +419 -388
- data/lib/Miyako/API/viewport.rb +189 -139
- data/lib/Miyako/API/yuki.rb +1226 -996
- data/lib/Miyako/EXT/miyako_cairo.rb +62 -62
- data/lib/Miyako/EXT/raster_scroll.rb +138 -138
- data/lib/Miyako/EXT/slides.rb +157 -157
- data/lib/Miyako/miyako.rb +201 -171
- data/lib/Miyako/miyako_require_only.rb +35 -0
- data/miyako_basicdata.c +590 -590
- data/miyako_bitmap.c +1225 -1225
- data/miyako_collision.c +403 -403
- data/miyako_drawing.c +187 -187
- data/miyako_font.c +334 -334
- data/miyako_hsv.c +830 -830
- data/miyako_input_audio.c +254 -0
- data/miyako_layout.c +191 -191
- data/miyako_no_katana.c +1078 -1074
- data/miyako_sprite2.c +431 -0
- data/miyako_transform.c +438 -438
- data/miyako_utility.c +288 -288
- data/sample/Animation1/m1ku.rb +68 -68
- data/sample/Animation2/lex.rb +96 -96
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +328 -386
- data/sample/Room3/blue.rb +297 -297
- data/sample/Room3/ending.rb +180 -180
- data/sample/Room3/green.rb +220 -220
- data/sample/Room3/main.rb +119 -119
- data/sample/Room3/main_component.rb +59 -59
- data/sample/Room3/red.rb +227 -227
- data/sample/Room3/room3.rb +25 -27
- data/sample/Room3/title.rb +184 -184
- data/sample/ball_action_sample.rb +204 -204
- data/sample/blit_rop.rb +70 -70
- data/sample/cairo_sample.rb +25 -25
- data/sample/circle_collision_test.rb +66 -66
- data/sample/collision_test.rb +33 -33
- data/sample/collision_test2.rb +108 -108
- data/sample/fixed_map_test/fixed_map_sample.rb +140 -140
- data/sample/fixed_map_test/readme.txt +72 -72
- data/sample/map_test/chara.rb +58 -58
- data/sample/map_test/main_parts.rb +69 -69
- data/sample/map_test/main_scene.rb +153 -153
- data/sample/map_test/map_manager.rb +75 -75
- data/sample/map_test/map_test.rb +23 -23
- data/sample/map_test/oasis.rb +71 -71
- data/sample/map_test/readme.txt +89 -89
- data/sample/map_test/route.rb +157 -157
- data/sample/map_test/town.rb +74 -74
- data/sample/polygon_test.rb +35 -35
- data/sample/rasterscroll.rb +24 -24
- data/sample/takahashi.rb +42 -42
- data/sample/textbox_sample.rb +189 -189
- data/sample/transform.rb +54 -54
- data/sample/utility_test.rb +73 -73
- data/sample/utility_test2.rb +61 -61
- data/sample/utility_test3.rb +64 -64
- data/sample/utility_test4.rb +73 -73
- data/uninstall_miyako.rb +19 -19
- data/win/miyako_no_katana.so +0 -0
- metadata +7 -2
data/miyako_no_katana.c
CHANGED
@@ -1,1074 +1,1078 @@
|
|
1
|
-
/*
|
2
|
-
--
|
3
|
-
Miyako v2.0 Extend Library "Miyako no Katana"
|
4
|
-
Copyright (C) 2008 Cyross Makoto
|
5
|
-
|
6
|
-
This library is free software; you can redistribute it and/or
|
7
|
-
modify it under the terms of the GNU Lesser General Public
|
8
|
-
License as published by the Free Software Foundation; either
|
9
|
-
version 2.1 of the License, or (at your option) any later version.
|
10
|
-
|
11
|
-
This library is distributed in the hope that it will be useful,
|
12
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
-
Lesser General Public License for more details.
|
15
|
-
|
16
|
-
You should have received a copy of the GNU Lesser General Public
|
17
|
-
License along with this library; if not, write to the Free Software
|
18
|
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
-
++
|
20
|
-
*/
|
21
|
-
|
22
|
-
/*
|
23
|
-
=拡張ライブラリmiyako_no_katana
|
24
|
-
Authors:: サイロス誠
|
25
|
-
Version:: 2.0
|
26
|
-
Copyright:: 2007-2008 Cyross Makoto
|
27
|
-
License:: LGPL2.1
|
28
|
-
*/
|
29
|
-
#include "defines.h"
|
30
|
-
#include "extern.h"
|
31
|
-
|
32
|
-
static VALUE mSDL = Qnil;
|
33
|
-
static VALUE mMiyako = Qnil;
|
34
|
-
static VALUE mScreen = Qnil;
|
35
|
-
static VALUE mDiagram = Qnil;
|
36
|
-
static VALUE cSurface = Qnil;
|
37
|
-
static VALUE cGL = Qnil;
|
38
|
-
static VALUE cFont = Qnil;
|
39
|
-
static VALUE cThread = Qnil;
|
40
|
-
static VALUE cSprite = Qnil;
|
41
|
-
static VALUE cSpriteAnimation = Qnil;
|
42
|
-
static VALUE cPlane = Qnil;
|
43
|
-
static VALUE cParts = Qnil;
|
44
|
-
static VALUE cMap = Qnil;
|
45
|
-
static VALUE cMapLayer = Qnil;
|
46
|
-
static VALUE cFixedMap = Qnil;
|
47
|
-
static VALUE cFixedMapLayer = Qnil;
|
48
|
-
static VALUE cProcessor = Qnil;
|
49
|
-
static VALUE nZero = Qnil;
|
50
|
-
static VALUE nOne = Qnil;
|
51
|
-
static volatile ID id_update = Qnil;
|
52
|
-
static volatile ID id_kakko = Qnil;
|
53
|
-
static volatile ID id_render = Qnil;
|
54
|
-
static volatile ID id_to_a = Qnil;
|
55
|
-
static volatile int zero = Qnil;
|
56
|
-
static volatile int one = Qnil;
|
57
|
-
|
58
|
-
// from rubysdl_video.c
|
59
|
-
static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
|
60
|
-
|
61
|
-
static VALUE use_opengl = Qnil;
|
62
|
-
|
63
|
-
extern void Init_miyako_bitmap();
|
64
|
-
extern void Init_miyako_transform();
|
65
|
-
extern void Init_miyako_hsv();
|
66
|
-
extern void Init_miyako_drawing();
|
67
|
-
extern void Init_miyako_layout();
|
68
|
-
extern void Init_miyako_collision();
|
69
|
-
extern void Init_miyako_basicdata();
|
70
|
-
extern void Init_miyako_font();
|
71
|
-
extern void Init_miyako_utility();
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if(
|
98
|
-
|
99
|
-
|
100
|
-
pdst
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
sb->color.
|
106
|
-
|
107
|
-
sb->color.
|
108
|
-
|
109
|
-
|
110
|
-
db->color.
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
if(
|
120
|
-
|
121
|
-
|
122
|
-
pdst
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
sb->color.
|
130
|
-
|
131
|
-
|
132
|
-
db->color.
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
int
|
205
|
-
int
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
VALUE
|
271
|
-
|
272
|
-
VALUE
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
int
|
327
|
-
int
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
if(pos_x
|
352
|
-
if(pos_y
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
int
|
357
|
-
int
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
int
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
dst
|
381
|
-
|
382
|
-
|
383
|
-
}
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
int
|
393
|
-
int
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
int
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
dst
|
425
|
-
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
int
|
437
|
-
int
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
if(pos_x
|
462
|
-
if(pos_y
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
int
|
467
|
-
int
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
int
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
dst
|
488
|
-
|
489
|
-
|
490
|
-
}
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
int
|
500
|
-
int
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
int
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
dst
|
532
|
-
|
533
|
-
|
534
|
-
}
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
VALUE
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
pnum = (
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
pnum = (
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
if(
|
760
|
-
|
761
|
-
|
762
|
-
is_change =
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
VALUE
|
775
|
-
|
776
|
-
VALUE
|
777
|
-
VALUE
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
int
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
VALUE
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
*(runit +
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
*(runit +
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
VALUE
|
815
|
-
|
816
|
-
VALUE
|
817
|
-
VALUE
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
int
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
VALUE
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
*(runit +
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
*(runit +
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
VALUE
|
856
|
-
|
857
|
-
VALUE
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
int
|
865
|
-
int
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
int
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
VALUE
|
897
|
-
|
898
|
-
VALUE
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
int
|
906
|
-
int
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
int
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
VALUE
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
VALUE
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
VALUE
|
978
|
-
VALUE
|
979
|
-
VALUE
|
980
|
-
VALUE
|
981
|
-
VALUE
|
982
|
-
|
983
|
-
VALUE
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
rb_funcall(mutex, rb_intern("
|
990
|
-
rb_funcall(
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
rb_define_module_function(mScreen, "
|
1033
|
-
rb_define_module_function(mScreen, "
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
rb_define_method(cSpriteAnimation, "
|
1038
|
-
rb_define_method(cSpriteAnimation, "
|
1039
|
-
rb_define_method(cSpriteAnimation, "
|
1040
|
-
rb_define_method(cSpriteAnimation, "
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
rb_define_method(
|
1047
|
-
|
1048
|
-
|
1049
|
-
rb_define_method(
|
1050
|
-
|
1051
|
-
|
1052
|
-
rb_define_method(
|
1053
|
-
|
1054
|
-
rb_define_method(
|
1055
|
-
|
1056
|
-
rb_define_method(
|
1057
|
-
rb_define_method(
|
1058
|
-
rb_define_method(cMap, "
|
1059
|
-
rb_define_method(cFixedMap, "
|
1060
|
-
rb_define_method(
|
1061
|
-
rb_define_method(
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1
|
+
/*
|
2
|
+
--
|
3
|
+
Miyako v2.0 Extend Library "Miyako no Katana"
|
4
|
+
Copyright (C) 2008 Cyross Makoto
|
5
|
+
|
6
|
+
This library is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU Lesser General Public
|
8
|
+
License as published by the Free Software Foundation; either
|
9
|
+
version 2.1 of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This library is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public
|
17
|
+
License along with this library; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
++
|
20
|
+
*/
|
21
|
+
|
22
|
+
/*
|
23
|
+
=拡張ライブラリmiyako_no_katana
|
24
|
+
Authors:: サイロス誠
|
25
|
+
Version:: 2.0
|
26
|
+
Copyright:: 2007-2008 Cyross Makoto
|
27
|
+
License:: LGPL2.1
|
28
|
+
*/
|
29
|
+
#include "defines.h"
|
30
|
+
#include "extern.h"
|
31
|
+
|
32
|
+
static VALUE mSDL = Qnil;
|
33
|
+
static VALUE mMiyako = Qnil;
|
34
|
+
static VALUE mScreen = Qnil;
|
35
|
+
static VALUE mDiagram = Qnil;
|
36
|
+
static VALUE cSurface = Qnil;
|
37
|
+
static VALUE cGL = Qnil;
|
38
|
+
static VALUE cFont = Qnil;
|
39
|
+
static VALUE cThread = Qnil;
|
40
|
+
static VALUE cSprite = Qnil;
|
41
|
+
static VALUE cSpriteAnimation = Qnil;
|
42
|
+
static VALUE cPlane = Qnil;
|
43
|
+
static VALUE cParts = Qnil;
|
44
|
+
static VALUE cMap = Qnil;
|
45
|
+
static VALUE cMapLayer = Qnil;
|
46
|
+
static VALUE cFixedMap = Qnil;
|
47
|
+
static VALUE cFixedMapLayer = Qnil;
|
48
|
+
static VALUE cProcessor = Qnil;
|
49
|
+
static VALUE nZero = Qnil;
|
50
|
+
static VALUE nOne = Qnil;
|
51
|
+
static volatile ID id_update = Qnil;
|
52
|
+
static volatile ID id_kakko = Qnil;
|
53
|
+
static volatile ID id_render = Qnil;
|
54
|
+
static volatile ID id_to_a = Qnil;
|
55
|
+
static volatile int zero = Qnil;
|
56
|
+
static volatile int one = Qnil;
|
57
|
+
|
58
|
+
// from rubysdl_video.c
|
59
|
+
static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
|
60
|
+
|
61
|
+
static VALUE use_opengl = Qnil;
|
62
|
+
|
63
|
+
extern void Init_miyako_bitmap();
|
64
|
+
extern void Init_miyako_transform();
|
65
|
+
extern void Init_miyako_hsv();
|
66
|
+
extern void Init_miyako_drawing();
|
67
|
+
extern void Init_miyako_layout();
|
68
|
+
extern void Init_miyako_collision();
|
69
|
+
extern void Init_miyako_basicdata();
|
70
|
+
extern void Init_miyako_font();
|
71
|
+
extern void Init_miyako_utility();
|
72
|
+
extern void Init_miyako_sprite2();
|
73
|
+
extern void Init_miyako_input_audio();
|
74
|
+
|
75
|
+
/*
|
76
|
+
===内部用レンダメソッド
|
77
|
+
*/
|
78
|
+
static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
|
79
|
+
{
|
80
|
+
if(sb->ptr == db->ptr){ return; }
|
81
|
+
|
82
|
+
MiyakoSize size;
|
83
|
+
if(_miyako_init_rect(sb, db, &size) == 0) return;
|
84
|
+
|
85
|
+
SDL_LockSurface(sb->surface);
|
86
|
+
SDL_LockSurface(db->surface);
|
87
|
+
|
88
|
+
int x, y;
|
89
|
+
for(y = 0; y < size.h; y++)
|
90
|
+
{
|
91
|
+
Uint32 *psrc = sb->ptr + (sb->rect.y + y) * sb->surface->w + sb->rect.x;
|
92
|
+
Uint32 *pdst = db->ptr + (db->rect.y + sb->y + y) * db->surface->w + db->rect.x + sb->x;
|
93
|
+
for(x = 0; x < size.w; x++)
|
94
|
+
{
|
95
|
+
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
96
|
+
sb->color.a = (*psrc >> 24) & 0xff | sb->a255;
|
97
|
+
if(sb->color.a == 0){ psrc++; pdst++; continue; }
|
98
|
+
db->color.a = (*pdst >> 24) & 0xff | db->a255;
|
99
|
+
if(db->color.a == 0 || sb->color.a == 255){
|
100
|
+
*pdst = *psrc | (sb->a255 << 24);
|
101
|
+
psrc++;
|
102
|
+
pdst++;
|
103
|
+
continue;
|
104
|
+
}
|
105
|
+
int a1 = sb->color.a + 1;
|
106
|
+
int a2 = 256 - sb->color.a;
|
107
|
+
sb->color.r = (*psrc >> 16) & 0xff;
|
108
|
+
sb->color.g = (*psrc >> 8) & 0xff;
|
109
|
+
sb->color.b = (*psrc ) & 0xff;
|
110
|
+
db->color.r = (*pdst >> 16) & 0xff;
|
111
|
+
db->color.g = (*pdst >> 8) & 0xff;
|
112
|
+
db->color.b = (*pdst ) & 0xff;
|
113
|
+
*pdst = ((sb->color.r * a1 + db->color.r * a2) >> 8) << 16 |
|
114
|
+
((sb->color.g * a1 + db->color.g * a2) >> 8) << 8 |
|
115
|
+
((sb->color.b * a1 + db->color.b * a2) >> 8) |
|
116
|
+
0xff << 24;
|
117
|
+
#else
|
118
|
+
sb->color.a = (*psrc & sb->fmt->Amask) | sb->a255;
|
119
|
+
if(sb->color.a == 0){ psrc++; pdst++; continue; }
|
120
|
+
db->color.a = (*pdst & db->fmt->Amask) | db->a255;
|
121
|
+
if(db->color.a == 0 || sb->color.a == 255){
|
122
|
+
*pdst = *psrc | sb->a255;
|
123
|
+
psrc++;
|
124
|
+
pdst++;
|
125
|
+
continue;
|
126
|
+
}
|
127
|
+
int a1 = sb->color.a + 1;
|
128
|
+
int a2 = 256 - sb->color.a;
|
129
|
+
sb->color.r = (*psrc & sb->fmt->Rmask) >> sb->fmt->Rshift;
|
130
|
+
sb->color.g = (*psrc & sb->fmt->Gmask) >> sb->fmt->Gshift;
|
131
|
+
sb->color.b = (*psrc & sb->fmt->Bmask) >> sb->fmt->Bshift;
|
132
|
+
db->color.r = (*pdst & db->fmt->Rmask) >> db->fmt->Rshift;
|
133
|
+
db->color.g = (*pdst & db->fmt->Gmask) >> db->fmt->Gshift;
|
134
|
+
db->color.b = (*pdst & db->fmt->Bmask) >> db->fmt->Bshift;
|
135
|
+
*pdst = ((sb->color.r * a1 + db->color.r * a2) >> 8) << db->fmt->Rshift |
|
136
|
+
((sb->color.g * a1 + db->color.g * a2) >> 8) << db->fmt->Gshift |
|
137
|
+
((sb->color.b * a1 + db->color.b * a2) >> 8) << db->fmt->Bshift |
|
138
|
+
0xff;
|
139
|
+
#endif
|
140
|
+
psrc++;
|
141
|
+
pdst++;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
SDL_UnlockSurface(sb->surface);
|
146
|
+
SDL_UnlockSurface(db->surface);
|
147
|
+
}
|
148
|
+
|
149
|
+
/*
|
150
|
+
===内部用レンダメソッド
|
151
|
+
*/
|
152
|
+
static void render_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
|
153
|
+
{
|
154
|
+
db->rect.x += sb->x;
|
155
|
+
db->rect.y += sb->y;
|
156
|
+
SDL_BlitSurface(sb->surface, &(sb->rect), db->surface, &(db->rect));
|
157
|
+
}
|
158
|
+
|
159
|
+
/*
|
160
|
+
インスタンスの内容を別のインスタンスに描画する
|
161
|
+
*/
|
162
|
+
static VALUE sprite_c_render_to_sprite(VALUE self, VALUE vsrc, VALUE vdst)
|
163
|
+
{
|
164
|
+
MiyakoBitmap src, dst;
|
165
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
166
|
+
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
167
|
+
render_to_inner(&src, &dst);
|
168
|
+
return self;
|
169
|
+
}
|
170
|
+
|
171
|
+
/*
|
172
|
+
インスタンスの内容を画面に描画する
|
173
|
+
*/
|
174
|
+
static VALUE sprite_render(VALUE self)
|
175
|
+
{
|
176
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
177
|
+
if(visible == Qfalse) return self;
|
178
|
+
MiyakoBitmap src, dst;
|
179
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
180
|
+
_miyako_setup_unit_2(self, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
|
181
|
+
render_inner(&src, &dst);
|
182
|
+
return self;
|
183
|
+
}
|
184
|
+
|
185
|
+
/*
|
186
|
+
インスタンスの内容を別のインスタンスに描画する
|
187
|
+
*/
|
188
|
+
static VALUE sprite_render_to_sprite(VALUE self, VALUE vdst)
|
189
|
+
{
|
190
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
191
|
+
if(visible == Qfalse) return self;
|
192
|
+
MiyakoBitmap src, dst;
|
193
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
194
|
+
_miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
195
|
+
render_to_inner(&src, &dst);
|
196
|
+
return self;
|
197
|
+
}
|
198
|
+
|
199
|
+
/*
|
200
|
+
:nodoc:
|
201
|
+
*/
|
202
|
+
static VALUE screen_update_tick(VALUE self)
|
203
|
+
{
|
204
|
+
int t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
|
205
|
+
int tt = NUM2INT(rb_iv_get(mScreen, "@@t"));
|
206
|
+
int interval = t - tt;
|
207
|
+
int fps_cnt = NUM2INT(rb_iv_get(mScreen, "@@fpscnt"));
|
208
|
+
|
209
|
+
while(interval < fps_cnt){
|
210
|
+
t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
|
211
|
+
interval = t - tt;
|
212
|
+
}
|
213
|
+
|
214
|
+
rb_iv_set(mScreen, "@@t", INT2NUM(t));
|
215
|
+
rb_iv_set(mScreen, "@@interval", INT2NUM(interval));
|
216
|
+
|
217
|
+
return Qnil;
|
218
|
+
}
|
219
|
+
|
220
|
+
/*
|
221
|
+
:nodoc:
|
222
|
+
*/
|
223
|
+
static VALUE render_auto_render_array(VALUE array)
|
224
|
+
{
|
225
|
+
int len = RARRAY_LEN(array);
|
226
|
+
if(len == 0){ return Qnil; }
|
227
|
+
VALUE *ptr = RARRAY_PTR(array);
|
228
|
+
|
229
|
+
int i;
|
230
|
+
for(i=0; i<len; i++)
|
231
|
+
{
|
232
|
+
VALUE v = *ptr;
|
233
|
+
if(v == Qnil)
|
234
|
+
{
|
235
|
+
ptr++;
|
236
|
+
continue;
|
237
|
+
}
|
238
|
+
else if(TYPE(v) == T_ARRAY)
|
239
|
+
{
|
240
|
+
render_auto_render_array(v);
|
241
|
+
}
|
242
|
+
else
|
243
|
+
{
|
244
|
+
rb_funcall(v, id_render, 0);
|
245
|
+
}
|
246
|
+
ptr++;
|
247
|
+
}
|
248
|
+
|
249
|
+
return Qnil;
|
250
|
+
}
|
251
|
+
|
252
|
+
/*
|
253
|
+
:nodoc:
|
254
|
+
*/
|
255
|
+
static VALUE screen_pre_render(VALUE self)
|
256
|
+
{
|
257
|
+
VALUE pre_render_array = rb_iv_get(mScreen, "@@pre_render_array");
|
258
|
+
if(RARRAY_LEN(pre_render_array) > 0)
|
259
|
+
{
|
260
|
+
render_auto_render_array(pre_render_array);
|
261
|
+
}
|
262
|
+
return Qnil;
|
263
|
+
}
|
264
|
+
|
265
|
+
/*
|
266
|
+
画面を更新する
|
267
|
+
*/
|
268
|
+
static VALUE screen_render(VALUE self)
|
269
|
+
{
|
270
|
+
VALUE dst = rb_iv_get(mScreen, "@@unit");
|
271
|
+
SDL_Surface *pdst = GetSurface(*(RSTRUCT_PTR(dst)))->surface;
|
272
|
+
VALUE fps_view = rb_iv_get(mScreen, "@@fpsView");
|
273
|
+
|
274
|
+
VALUE auto_render_array = rb_iv_get(mScreen, "@@auto_render_array");
|
275
|
+
if(RARRAY_LEN(auto_render_array) > 0)
|
276
|
+
{
|
277
|
+
render_auto_render_array(auto_render_array);
|
278
|
+
}
|
279
|
+
|
280
|
+
if(fps_view == Qtrue){
|
281
|
+
char str[256];
|
282
|
+
int interval = NUM2INT(rb_iv_get(mScreen, "@@interval"));
|
283
|
+
int fps_max = NUM2INT(rb_const_get(mScreen, rb_intern("FpsMax")));
|
284
|
+
VALUE sans_serif = rb_funcall(cFont, rb_intern("sans_serif"), 0);
|
285
|
+
VALUE fps_sprite = Qnil;
|
286
|
+
|
287
|
+
if(interval == 0){ interval = 1; }
|
288
|
+
|
289
|
+
sprintf(str, "%d fps", fps_max / interval);
|
290
|
+
VALUE fps_str = rb_str_new2((const char *)str);
|
291
|
+
|
292
|
+
fps_sprite = rb_funcall(fps_str, rb_intern("to_sprite"), 1, sans_serif);
|
293
|
+
sprite_render(fps_sprite);
|
294
|
+
}
|
295
|
+
|
296
|
+
screen_update_tick(self);
|
297
|
+
|
298
|
+
if(use_opengl == Qfalse)
|
299
|
+
{
|
300
|
+
SDL_Flip(pdst);
|
301
|
+
return Qnil;
|
302
|
+
}
|
303
|
+
rb_funcall(cGL, rb_intern("swap_buffers"), 0);
|
304
|
+
|
305
|
+
return Qnil;
|
306
|
+
}
|
307
|
+
|
308
|
+
/*
|
309
|
+
インスタンスの内容を画面に描画する
|
310
|
+
*/
|
311
|
+
static VALUE screen_render_screen(VALUE self, VALUE vsrc)
|
312
|
+
{
|
313
|
+
MiyakoBitmap src, dst;
|
314
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
315
|
+
_miyako_setup_unit_2(vsrc, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
|
316
|
+
render_inner(&src, &dst);
|
317
|
+
return self;
|
318
|
+
}
|
319
|
+
|
320
|
+
|
321
|
+
/*
|
322
|
+
===マップレイヤー転送インナーメソッド
|
323
|
+
*/
|
324
|
+
static void maplayer_render_inner(VALUE self, MiyakoBitmap *dst)
|
325
|
+
{
|
326
|
+
int cw = NUM2INT(rb_iv_get(self, "@cw"));
|
327
|
+
int ch = NUM2INT(rb_iv_get(self, "@ch"));
|
328
|
+
int ow = NUM2INT(rb_iv_get(self, "@ow"));
|
329
|
+
int oh = NUM2INT(rb_iv_get(self, "@oh"));
|
330
|
+
|
331
|
+
VALUE margin = rb_iv_get(self, "@pos");
|
332
|
+
int pos_x = NUM2INT(*(RSTRUCT_PTR(margin) + 0));
|
333
|
+
int pos_y = NUM2INT(*(RSTRUCT_PTR(margin) + 1));
|
334
|
+
|
335
|
+
VALUE size = rb_iv_get(self, "@size");
|
336
|
+
int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
|
337
|
+
int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
|
338
|
+
|
339
|
+
VALUE real_size = rb_iv_get(self, "@real_size");
|
340
|
+
int real_size_w = NUM2INT(*(RSTRUCT_PTR(real_size) + 0));
|
341
|
+
int real_size_h = NUM2INT(*(RSTRUCT_PTR(real_size) + 1));
|
342
|
+
|
343
|
+
VALUE param = rb_iv_get(self, "@mapchip");
|
344
|
+
VALUE mc_chip_size = *(RSTRUCT_PTR(param) + 3);
|
345
|
+
int mc_chip_size_w = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 0));
|
346
|
+
int mc_chip_size_h = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 1));
|
347
|
+
|
348
|
+
VALUE munits = rb_iv_get(self, "@mapchip_units");
|
349
|
+
VALUE mapdat = rb_iv_get(self, "@mapdat");
|
350
|
+
|
351
|
+
if(pos_x < 0){ pos_x = real_size_w + (pos_x % real_size_w); }
|
352
|
+
if(pos_y < 0){ pos_y = real_size_h + (pos_y % real_size_h); }
|
353
|
+
if(pos_x >= real_size_w){ pos_x %= real_size_w; }
|
354
|
+
if(pos_y >= real_size_h){ pos_y %= real_size_h; }
|
355
|
+
|
356
|
+
int dx = pos_x / mc_chip_size_w;
|
357
|
+
int mx = pos_x % mc_chip_size_w;
|
358
|
+
int dy = pos_y / mc_chip_size_h;
|
359
|
+
int my = pos_y % mc_chip_size_h;
|
360
|
+
|
361
|
+
MiyakoBitmap src;
|
362
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
363
|
+
|
364
|
+
int bx = dst->rect.x;
|
365
|
+
int by = dst->rect.y;
|
366
|
+
|
367
|
+
int x, y, idx1, idx2;
|
368
|
+
for(y = 0; y < ch; y++){
|
369
|
+
idx1 = (y + dy) % size_h;
|
370
|
+
VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
|
371
|
+
for(x = 0; x < cw; x++){
|
372
|
+
idx2 = (x + dx) % size_w;
|
373
|
+
int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
|
374
|
+
if(code == -1){ continue; }
|
375
|
+
_miyako_setup_unit(
|
376
|
+
rb_funcall(*(RARRAY_PTR(munits) + code),
|
377
|
+
rb_intern("to_unit"), 0),
|
378
|
+
scr, &src,
|
379
|
+
INT2NUM(x * ow - mx), INT2NUM(y * oh - my), 0);
|
380
|
+
render_inner(&src, dst);
|
381
|
+
dst->rect.x = bx;
|
382
|
+
dst->rect.y = by;
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
/*
|
388
|
+
===固定マップレイヤー転送インナーメソッド
|
389
|
+
*/
|
390
|
+
static void fixedmaplayer_render_inner(VALUE self, MiyakoBitmap *dst)
|
391
|
+
{
|
392
|
+
int cw = NUM2INT(rb_iv_get(self, "@cw"));
|
393
|
+
int ch = NUM2INT(rb_iv_get(self, "@ch"));
|
394
|
+
int ow = NUM2INT(rb_iv_get(self, "@ow"));
|
395
|
+
int oh = NUM2INT(rb_iv_get(self, "@oh"));
|
396
|
+
|
397
|
+
VALUE pos = rb_iv_get(self, "@pos");
|
398
|
+
int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
|
399
|
+
int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
|
400
|
+
|
401
|
+
VALUE size = rb_iv_get(self, "@size");
|
402
|
+
int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
|
403
|
+
int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
|
404
|
+
|
405
|
+
VALUE munits = rb_iv_get(self, "@mapchip_units");
|
406
|
+
VALUE mapdat = rb_iv_get(self, "@mapdat");
|
407
|
+
|
408
|
+
MiyakoBitmap src;
|
409
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
410
|
+
|
411
|
+
int bx = dst->rect.x;
|
412
|
+
int by = dst->rect.y;
|
413
|
+
|
414
|
+
int x, y, idx1, idx2;
|
415
|
+
for(y = 0; y < ch; y++){
|
416
|
+
idx1 = y % size_h;
|
417
|
+
VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
|
418
|
+
for(x = 0; x < cw; x++){
|
419
|
+
idx2 = x % size_w;
|
420
|
+
int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
|
421
|
+
if(code == -1){ continue; }
|
422
|
+
_miyako_setup_unit(rb_funcall(*(RARRAY_PTR(munits) + code), rb_intern("to_unit"), 0),
|
423
|
+
scr, &src, INT2NUM(pos_x + x * ow), INT2NUM(pos_y + y * oh), 0);
|
424
|
+
render_inner(&src, dst);
|
425
|
+
dst->rect.x = bx;
|
426
|
+
dst->rect.y = by;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
/*
|
432
|
+
===マップレイヤー転送インナーメソッド
|
433
|
+
*/
|
434
|
+
static void maplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
|
435
|
+
{
|
436
|
+
int cw = NUM2INT(rb_iv_get(self, "@cw"));
|
437
|
+
int ch = NUM2INT(rb_iv_get(self, "@ch"));
|
438
|
+
int ow = NUM2INT(rb_iv_get(self, "@ow"));
|
439
|
+
int oh = NUM2INT(rb_iv_get(self, "@oh"));
|
440
|
+
|
441
|
+
VALUE margin = rb_iv_get(self, "@pos");
|
442
|
+
int pos_x = NUM2INT(*(RSTRUCT_PTR(margin) + 0));
|
443
|
+
int pos_y = NUM2INT(*(RSTRUCT_PTR(margin) + 1));
|
444
|
+
|
445
|
+
VALUE size = rb_iv_get(self, "@size");
|
446
|
+
int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
|
447
|
+
int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
|
448
|
+
|
449
|
+
VALUE real_size = rb_iv_get(self, "@real_size");
|
450
|
+
int real_size_w = NUM2INT(*(RSTRUCT_PTR(real_size) + 0));
|
451
|
+
int real_size_h = NUM2INT(*(RSTRUCT_PTR(real_size) + 1));
|
452
|
+
|
453
|
+
VALUE param = rb_iv_get(self, "@mapchip");
|
454
|
+
VALUE mc_chip_size = *(RSTRUCT_PTR(param) + 3);
|
455
|
+
int mc_chip_size_w = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 0));
|
456
|
+
int mc_chip_size_h = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 1));
|
457
|
+
|
458
|
+
VALUE munits = rb_iv_get(self, "@mapchip_units");
|
459
|
+
VALUE mapdat = rb_iv_get(self, "@mapdat");
|
460
|
+
|
461
|
+
if(pos_x < 0){ pos_x = real_size_w + (pos_x % real_size_w); }
|
462
|
+
if(pos_y < 0){ pos_y = real_size_h + (pos_y % real_size_h); }
|
463
|
+
if(pos_x >= real_size_w){ pos_x %= real_size_w; }
|
464
|
+
if(pos_y >= real_size_h){ pos_y %= real_size_h; }
|
465
|
+
|
466
|
+
int dx = pos_x / mc_chip_size_w;
|
467
|
+
int mx = pos_x % mc_chip_size_w;
|
468
|
+
int dy = pos_y / mc_chip_size_h;
|
469
|
+
int my = pos_y % mc_chip_size_h;
|
470
|
+
|
471
|
+
MiyakoBitmap src;
|
472
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
473
|
+
|
474
|
+
int bx = dst->rect.x;
|
475
|
+
int by = dst->rect.y;
|
476
|
+
|
477
|
+
int x, y, idx1, idx2;
|
478
|
+
for(y = 0; y < ch; y++){
|
479
|
+
idx1 = (y + dy) % size_h;
|
480
|
+
VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
|
481
|
+
for(x = 0; x < cw; x++){
|
482
|
+
idx2 = (x + dx) % size_w;
|
483
|
+
int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
|
484
|
+
if(code == -1){ continue; }
|
485
|
+
_miyako_setup_unit(rb_funcall(*(RARRAY_PTR(munits) + code), rb_intern("to_unit"), 0),
|
486
|
+
scr, &src, INT2NUM(x * ow - mx), INT2NUM(y * oh - my), 0);
|
487
|
+
render_inner(&src, dst);
|
488
|
+
dst->rect.x = bx;
|
489
|
+
dst->rect.y = by;
|
490
|
+
}
|
491
|
+
}
|
492
|
+
}
|
493
|
+
|
494
|
+
/*
|
495
|
+
===固定マップレイヤー転送インナーメソッド
|
496
|
+
*/
|
497
|
+
static void fixedmaplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
|
498
|
+
{
|
499
|
+
int cw = NUM2INT(rb_iv_get(self, "@cw"));
|
500
|
+
int ch = NUM2INT(rb_iv_get(self, "@ch"));
|
501
|
+
int ow = NUM2INT(rb_iv_get(self, "@ow"));
|
502
|
+
int oh = NUM2INT(rb_iv_get(self, "@oh"));
|
503
|
+
|
504
|
+
VALUE pos = rb_iv_get(self, "@pos");
|
505
|
+
int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
|
506
|
+
int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
|
507
|
+
|
508
|
+
VALUE size = rb_iv_get(self, "@size");
|
509
|
+
int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
|
510
|
+
int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
|
511
|
+
|
512
|
+
VALUE munits = rb_iv_get(self, "@mapchip_units");
|
513
|
+
VALUE mapdat = rb_iv_get(self, "@mapdat");
|
514
|
+
|
515
|
+
MiyakoBitmap src;
|
516
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
517
|
+
|
518
|
+
int bx = dst->rect.x;
|
519
|
+
int by = dst->rect.y;
|
520
|
+
|
521
|
+
int x, y, idx1, idx2;
|
522
|
+
for(y = 0; y < ch; y++){
|
523
|
+
idx1 = y % size_h;
|
524
|
+
VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
|
525
|
+
for(x = 0; x < cw; x++){
|
526
|
+
idx2 = x % size_w;
|
527
|
+
int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
|
528
|
+
if(code == -1){ continue; }
|
529
|
+
_miyako_setup_unit(rb_funcall(*(RARRAY_PTR(munits) + code), rb_intern("to_unit"), 0),
|
530
|
+
scr, &src, INT2NUM(pos_x + x * ow), INT2NUM(pos_y + y * oh), 0);
|
531
|
+
render_inner(&src, dst);
|
532
|
+
dst->rect.x = bx;
|
533
|
+
dst->rect.y = by;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
}
|
537
|
+
|
538
|
+
/*
|
539
|
+
マップレイヤーを画面に描画する
|
540
|
+
*/
|
541
|
+
static VALUE maplayer_render(VALUE self)
|
542
|
+
{
|
543
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
544
|
+
if(visible == Qfalse) return self;
|
545
|
+
MiyakoBitmap dst;
|
546
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
547
|
+
_miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
|
548
|
+
maplayer_render_inner(self, &dst);
|
549
|
+
return self;
|
550
|
+
}
|
551
|
+
|
552
|
+
/*
|
553
|
+
マップレイヤーを画面に描画する
|
554
|
+
*/
|
555
|
+
static VALUE fixedmaplayer_render(VALUE self)
|
556
|
+
{
|
557
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
558
|
+
if(visible == Qfalse) return self;
|
559
|
+
MiyakoBitmap dst;
|
560
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
561
|
+
_miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
|
562
|
+
fixedmaplayer_render_inner(self, &dst);
|
563
|
+
return self;
|
564
|
+
}
|
565
|
+
|
566
|
+
/*
|
567
|
+
マップレイヤーを画像に転送する
|
568
|
+
*/
|
569
|
+
static VALUE maplayer_render_to_sprite(VALUE self, VALUE vdst)
|
570
|
+
{
|
571
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
572
|
+
if(visible == Qfalse) return self;
|
573
|
+
MiyakoBitmap dst;
|
574
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
575
|
+
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
576
|
+
maplayer_render_to_inner(self, &dst);
|
577
|
+
return self;
|
578
|
+
}
|
579
|
+
|
580
|
+
/*
|
581
|
+
マップレイヤーを画像に転送する
|
582
|
+
*/
|
583
|
+
static VALUE fixedmaplayer_render_to_sprite(VALUE self, VALUE vdst)
|
584
|
+
{
|
585
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
586
|
+
if(visible == Qfalse) return self;
|
587
|
+
MiyakoBitmap dst;
|
588
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
589
|
+
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
590
|
+
maplayer_render_inner(self, &dst);
|
591
|
+
return self;
|
592
|
+
}
|
593
|
+
|
594
|
+
/*
|
595
|
+
マップを画面に描画する
|
596
|
+
*/
|
597
|
+
static VALUE map_render(VALUE self)
|
598
|
+
{
|
599
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
600
|
+
if(visible == Qfalse) return self;
|
601
|
+
MiyakoBitmap dst;
|
602
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
603
|
+
_miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
|
604
|
+
VALUE map_layers = rb_iv_get(self, "@map_layers");
|
605
|
+
int i;
|
606
|
+
for(i=0; i<RARRAY_LEN(map_layers); i++){
|
607
|
+
maplayer_render_inner(*(RARRAY_PTR(map_layers) + i), &dst);
|
608
|
+
}
|
609
|
+
|
610
|
+
return self;
|
611
|
+
}
|
612
|
+
|
613
|
+
/*
|
614
|
+
マップを画面に描画する
|
615
|
+
*/
|
616
|
+
static VALUE fixedmap_render(VALUE self)
|
617
|
+
{
|
618
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
619
|
+
if(visible == Qfalse) return self;
|
620
|
+
MiyakoBitmap dst;
|
621
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
622
|
+
_miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
|
623
|
+
VALUE map_layers = rb_iv_get(self, "@map_layers");
|
624
|
+
int i;
|
625
|
+
for(i=0; i<RARRAY_LEN(map_layers); i++){
|
626
|
+
fixedmaplayer_render_inner(*(RARRAY_PTR(map_layers) + i), &dst);
|
627
|
+
}
|
628
|
+
|
629
|
+
return self;
|
630
|
+
}
|
631
|
+
|
632
|
+
/*
|
633
|
+
マップを画像に描画する
|
634
|
+
*/
|
635
|
+
static VALUE map_render_to_sprite(VALUE self, VALUE vdst)
|
636
|
+
{
|
637
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
638
|
+
if(visible == Qfalse) return self;
|
639
|
+
MiyakoBitmap dst;
|
640
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
641
|
+
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
642
|
+
|
643
|
+
VALUE map_layers = rb_iv_get(self, "@map_layers");
|
644
|
+
int i;
|
645
|
+
for(i=0; i<RARRAY_LEN(map_layers); i++){
|
646
|
+
maplayer_render_to_inner(*(RARRAY_PTR(map_layers) + i), &dst);
|
647
|
+
}
|
648
|
+
|
649
|
+
return self;
|
650
|
+
}
|
651
|
+
|
652
|
+
/*
|
653
|
+
マップを画像に描画する
|
654
|
+
*/
|
655
|
+
static VALUE fixedmap_render_to_sprite(VALUE self, VALUE vdst)
|
656
|
+
{
|
657
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
658
|
+
if(visible == Qfalse) return self;
|
659
|
+
MiyakoBitmap dst;
|
660
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
661
|
+
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
662
|
+
|
663
|
+
VALUE map_layers = rb_iv_get(self, "@map_layers");
|
664
|
+
int i;
|
665
|
+
for(i=0; i<RARRAY_LEN(map_layers); i++){
|
666
|
+
fixedmaplayer_render_to_inner(*(RARRAY_PTR(map_layers) + i), &dst);
|
667
|
+
}
|
668
|
+
|
669
|
+
return self;
|
670
|
+
}
|
671
|
+
|
672
|
+
/*
|
673
|
+
:nodoc:
|
674
|
+
*/
|
675
|
+
static VALUE sa_set_pat(VALUE self)
|
676
|
+
{
|
677
|
+
VALUE num = rb_iv_get(self, "@pnum");
|
678
|
+
VALUE plist = rb_iv_get(self, "@plist");
|
679
|
+
VALUE units = rb_iv_get(self, "@units");
|
680
|
+
rb_iv_set(self, "@now", *(RARRAY_PTR(units) + NUM2INT(*(RARRAY_PTR(plist) + NUM2INT(num)))));
|
681
|
+
return self;
|
682
|
+
}
|
683
|
+
|
684
|
+
/*
|
685
|
+
:nodoc:
|
686
|
+
*/
|
687
|
+
static VALUE sa_update_frame(VALUE self)
|
688
|
+
{
|
689
|
+
int cnt = NUM2INT(rb_iv_get(self, "@cnt"));
|
690
|
+
|
691
|
+
if(cnt > 0){
|
692
|
+
cnt--;
|
693
|
+
rb_iv_set(self, "@cnt", INT2NUM(cnt));
|
694
|
+
return Qfalse;
|
695
|
+
}
|
696
|
+
|
697
|
+
VALUE num = rb_iv_get(self, "@pnum");
|
698
|
+
VALUE loop = rb_iv_get(self, "@loop");
|
699
|
+
|
700
|
+
int pnum = NUM2INT(num);
|
701
|
+
int pats = NUM2INT(rb_iv_get(self, "@pats"));
|
702
|
+
pnum = (pnum + 1) % pats;
|
703
|
+
|
704
|
+
rb_iv_set(self, "@pnum", INT2NUM(pnum));
|
705
|
+
|
706
|
+
if(loop == Qfalse && pnum == 0){
|
707
|
+
rb_funcall(self, rb_intern("stop"), 0);
|
708
|
+
return Qfalse;
|
709
|
+
}
|
710
|
+
|
711
|
+
sa_set_pat(self);
|
712
|
+
VALUE plist = rb_iv_get(self, "@plist");
|
713
|
+
VALUE waits = rb_iv_get(self, "@waits");
|
714
|
+
rb_iv_set(self, "@cnt", *(RARRAY_PTR(waits) + NUM2INT(*(RARRAY_PTR(plist) + pnum))));
|
715
|
+
|
716
|
+
return Qtrue;
|
717
|
+
}
|
718
|
+
|
719
|
+
/*
|
720
|
+
:nodoc:
|
721
|
+
*/
|
722
|
+
static VALUE sa_update_wait_counter(VALUE self)
|
723
|
+
{
|
724
|
+
VALUE cnt = rb_iv_get(self, "@cnt");
|
725
|
+
VALUE waiting = rb_funcall(cnt, rb_intern("waiting?"), 0);
|
726
|
+
|
727
|
+
if(waiting == Qtrue) return Qfalse;
|
728
|
+
|
729
|
+
VALUE num = rb_iv_get(self, "@pnum");
|
730
|
+
VALUE loop = rb_iv_get(self, "@loop");
|
731
|
+
|
732
|
+
int pnum = NUM2INT(num);
|
733
|
+
int pats = NUM2INT(rb_iv_get(self, "@pats"));
|
734
|
+
pnum = (pnum + 1) % pats;
|
735
|
+
|
736
|
+
rb_iv_set(self, "@pnum", INT2NUM(pnum));
|
737
|
+
|
738
|
+
if(loop == Qfalse && pnum == 0){
|
739
|
+
rb_funcall(self, rb_intern("stop"), 0);
|
740
|
+
return Qfalse;
|
741
|
+
}
|
742
|
+
|
743
|
+
sa_set_pat(self);
|
744
|
+
VALUE plist = rb_iv_get(self, "@plist");
|
745
|
+
VALUE waits = rb_iv_get(self, "@waits");
|
746
|
+
cnt = *(RARRAY_PTR(waits) + NUM2INT(*(RARRAY_PTR(plist) + pnum)));
|
747
|
+
rb_iv_set(self, "@cnt", cnt);
|
748
|
+
rb_funcall(cnt, rb_intern("start"), 0);
|
749
|
+
return Qtrue;
|
750
|
+
}
|
751
|
+
|
752
|
+
/*
|
753
|
+
:nodoc:
|
754
|
+
*/
|
755
|
+
static VALUE sa_update(VALUE self)
|
756
|
+
{
|
757
|
+
VALUE is_change = Qfalse;
|
758
|
+
VALUE exec = rb_iv_get(self, "@exec");
|
759
|
+
if(exec == Qfalse){ return is_change; }
|
760
|
+
|
761
|
+
if(rb_obj_is_kind_of(rb_iv_get(self, "@cnt"), rb_cInteger) == Qtrue)
|
762
|
+
is_change = sa_update_frame(self);
|
763
|
+
else
|
764
|
+
is_change = sa_update_wait_counter(self);
|
765
|
+
|
766
|
+
return is_change;
|
767
|
+
}
|
768
|
+
|
769
|
+
/*
|
770
|
+
アニメーションの現在の画像を画面に描画する
|
771
|
+
*/
|
772
|
+
static VALUE sa_render(VALUE self)
|
773
|
+
{
|
774
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
775
|
+
if(visible == Qfalse) return self;
|
776
|
+
VALUE vsrc = rb_iv_get(self, "@now");
|
777
|
+
VALUE *runit = RSTRUCT_PTR(vsrc);
|
778
|
+
VALUE polist = rb_iv_get(self, "@pos_offset");
|
779
|
+
VALUE dir = rb_iv_get(self, "@dir");
|
780
|
+
|
781
|
+
int num = NUM2INT(rb_iv_get(self, "@pnum"));
|
782
|
+
|
783
|
+
VALUE *move_off = RARRAY_PTR(rb_funcall(*(RARRAY_PTR(rb_iv_get(self, "@move_offset")) + num), id_to_a, 0));
|
784
|
+
|
785
|
+
int pos_off = NUM2INT(*(RARRAY_PTR(polist) + num));
|
786
|
+
|
787
|
+
int didx = (rb_to_id(dir) == rb_intern("h") ? 2 : 1);
|
788
|
+
|
789
|
+
VALUE tmp_oxy = *(runit + didx);
|
790
|
+
VALUE tmp_x = *(runit + 5);
|
791
|
+
VALUE tmp_y = *(runit + 6);
|
792
|
+
|
793
|
+
*(runit + didx) = INT2NUM(NUM2INT(tmp_oxy) - pos_off);
|
794
|
+
*(runit + 5) = INT2NUM(NUM2INT(tmp_x) + NUM2INT(*(move_off+0)));
|
795
|
+
*(runit + 6) = INT2NUM(NUM2INT(tmp_y) + NUM2INT(*(move_off+1)));
|
796
|
+
|
797
|
+
MiyakoBitmap src, dst;
|
798
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
799
|
+
_miyako_setup_unit_2(vsrc, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
|
800
|
+
render_inner(&src, &dst);
|
801
|
+
|
802
|
+
*(runit + 5) = tmp_x;
|
803
|
+
*(runit + 6) = tmp_y;
|
804
|
+
*(runit + didx) = tmp_oxy;
|
805
|
+
|
806
|
+
return Qnil;
|
807
|
+
}
|
808
|
+
|
809
|
+
/*
|
810
|
+
アニメーションの現在の画像を画像に描画する
|
811
|
+
*/
|
812
|
+
static VALUE sa_render_to_sprite(VALUE self, VALUE vdst)
|
813
|
+
{
|
814
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
815
|
+
if(visible == Qfalse) return self;
|
816
|
+
VALUE vsrc = rb_iv_get(self, "@now");
|
817
|
+
VALUE *runit = RSTRUCT_PTR(vsrc);
|
818
|
+
VALUE polist = rb_iv_get(self, "@pos_offset");
|
819
|
+
VALUE dir = rb_iv_get(self, "@dir");
|
820
|
+
|
821
|
+
int num = NUM2INT(rb_iv_get(self, "@pnum"));
|
822
|
+
|
823
|
+
int pos_off = NUM2INT(*(RARRAY_PTR(polist) + num));
|
824
|
+
|
825
|
+
VALUE molist = rb_iv_get(self, "@move_offset");
|
826
|
+
VALUE move_off = *(RARRAY_PTR(molist) + num);
|
827
|
+
|
828
|
+
int didx = (rb_to_id(dir) == rb_intern("h") ? 3 : 2);
|
829
|
+
|
830
|
+
VALUE tmp_oxy = *(runit + didx);
|
831
|
+
VALUE tmp_x = *(runit + 5);
|
832
|
+
VALUE tmp_y = *(runit + 6);
|
833
|
+
|
834
|
+
*(runit + didx) = INT2NUM(NUM2INT(tmp_oxy) - pos_off);
|
835
|
+
*(runit + 5) = INT2NUM(NUM2INT(tmp_x) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nZero)));
|
836
|
+
*(runit + 6) = INT2NUM(NUM2INT(tmp_y) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nOne )));
|
837
|
+
|
838
|
+
MiyakoBitmap src, dst;
|
839
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
840
|
+
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
841
|
+
render_to_inner(&src, &dst);
|
842
|
+
|
843
|
+
*(runit + 5) = tmp_x;
|
844
|
+
*(runit + 6) = tmp_y;
|
845
|
+
*(runit + didx) = tmp_oxy;
|
846
|
+
|
847
|
+
return Qnil;
|
848
|
+
}
|
849
|
+
|
850
|
+
/*
|
851
|
+
プレーンを画面に描画する
|
852
|
+
*/
|
853
|
+
static VALUE plane_render(VALUE self)
|
854
|
+
{
|
855
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
856
|
+
if(visible == Qfalse) return self;
|
857
|
+
VALUE sprite = rb_iv_get(self, "@sprite");
|
858
|
+
|
859
|
+
VALUE ssize = rb_iv_get(mScreen, "@@size");
|
860
|
+
int ssw = NUM2INT(*(RSTRUCT_PTR(ssize) + 0));
|
861
|
+
int ssh = NUM2INT(*(RSTRUCT_PTR(ssize) + 1));
|
862
|
+
VALUE pos = rb_iv_get(self, "@pos");
|
863
|
+
VALUE size = rb_iv_get(self, "@size");
|
864
|
+
int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
|
865
|
+
int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
|
866
|
+
int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
|
867
|
+
int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
|
868
|
+
|
869
|
+
MiyakoBitmap src, dst;
|
870
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
871
|
+
_miyako_setup_unit_2(sprite, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
|
872
|
+
|
873
|
+
int sw = src.rect.w;
|
874
|
+
int sh = src.rect.h;
|
875
|
+
|
876
|
+
int x, y;
|
877
|
+
for(y = 0; y < h; y++){
|
878
|
+
for(x = 0; x < w; x++){
|
879
|
+
src.x = (x-1) * sw + pos_x;
|
880
|
+
src.y = (y-1) * sh + pos_y;
|
881
|
+
if(src.x > 0 || src.y > 0
|
882
|
+
|| (src.x+sw) <= ssw || (src.y+sh) <= ssh){
|
883
|
+
render_inner(&src, &dst);
|
884
|
+
}
|
885
|
+
}
|
886
|
+
}
|
887
|
+
|
888
|
+
return Qnil;
|
889
|
+
}
|
890
|
+
|
891
|
+
/*
|
892
|
+
プレーンを画像に描画する
|
893
|
+
*/
|
894
|
+
static VALUE plane_render_to_sprite(VALUE self, VALUE vdst)
|
895
|
+
{
|
896
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
897
|
+
if(visible == Qfalse) return self;
|
898
|
+
VALUE sprite = rb_iv_get(self, "@sprite");
|
899
|
+
|
900
|
+
VALUE ssize = rb_iv_get(mScreen, "@@size");
|
901
|
+
int ssw = NUM2INT(*(RSTRUCT_PTR(ssize) + 0));
|
902
|
+
int ssh = NUM2INT(*(RSTRUCT_PTR(ssize) + 1));
|
903
|
+
VALUE pos = rb_iv_get(self, "@pos");
|
904
|
+
VALUE size = rb_iv_get(self, "@size");
|
905
|
+
int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
|
906
|
+
int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
|
907
|
+
int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
|
908
|
+
int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
|
909
|
+
|
910
|
+
MiyakoBitmap src, dst;
|
911
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
912
|
+
_miyako_setup_unit_2(sprite, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
913
|
+
|
914
|
+
int sw = src.rect.w;
|
915
|
+
int sh = src.rect.h;
|
916
|
+
|
917
|
+
int x, y;
|
918
|
+
for(y = 0; y < h; y++){
|
919
|
+
for(x = 0; x < w; x++){
|
920
|
+
src.x = (x-1) * sw + pos_x;
|
921
|
+
src.y = (y-1) * sh + pos_y;
|
922
|
+
if(src.x > 0 || src.y > 0
|
923
|
+
|| (src.x+sw) <= ssw || (src.y+sh) <= ssh){
|
924
|
+
render_to_inner(&src, &dst);
|
925
|
+
}
|
926
|
+
}
|
927
|
+
}
|
928
|
+
|
929
|
+
return Qnil;
|
930
|
+
}
|
931
|
+
|
932
|
+
/*
|
933
|
+
パーツを画面に描画する
|
934
|
+
*/
|
935
|
+
static VALUE parts_render(VALUE self)
|
936
|
+
{
|
937
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
938
|
+
if(visible == Qfalse) return self;
|
939
|
+
VALUE parts_list = rb_iv_get(self, "@parts_list");
|
940
|
+
VALUE parts_hash = rb_iv_get(self, "@parts");
|
941
|
+
|
942
|
+
int i;
|
943
|
+
for(i=0; i<RARRAY_LEN(parts_list); i++)
|
944
|
+
{
|
945
|
+
VALUE parts = rb_hash_aref(parts_hash, *(RARRAY_PTR(parts_list) + i));
|
946
|
+
rb_funcall(parts, id_render, 0);
|
947
|
+
}
|
948
|
+
|
949
|
+
return Qnil;
|
950
|
+
}
|
951
|
+
|
952
|
+
/*
|
953
|
+
パーツを画面に描画する
|
954
|
+
*/
|
955
|
+
static VALUE parts_render_to_sprite(VALUE self, VALUE vdst)
|
956
|
+
{
|
957
|
+
VALUE visible = rb_iv_get(self, "@visible");
|
958
|
+
if(visible == Qfalse) return self;
|
959
|
+
VALUE parts_list = rb_iv_get(self, "@parts_list");
|
960
|
+
VALUE parts_hash = rb_iv_get(self, "@parts");
|
961
|
+
|
962
|
+
int i;
|
963
|
+
for(i=0; i<RARRAY_LEN(parts_list); i++)
|
964
|
+
{
|
965
|
+
VALUE parts = rb_hash_aref(parts_hash, *(RARRAY_PTR(parts_list) + i));
|
966
|
+
rb_funcall(parts, rb_intern("render_to"), 1, vdst);
|
967
|
+
}
|
968
|
+
|
969
|
+
return Qnil;
|
970
|
+
}
|
971
|
+
|
972
|
+
/*
|
973
|
+
:nodoc:
|
974
|
+
*/
|
975
|
+
static VALUE processor_mainloop(VALUE self)
|
976
|
+
{
|
977
|
+
VALUE diagram = rb_iv_get(self, "@diagram");
|
978
|
+
VALUE states = rb_iv_get(self, "@states");
|
979
|
+
VALUE mutex = rb_iv_get(self, "@mutex");
|
980
|
+
VALUE str_execute = rb_str_new2("execute");
|
981
|
+
VALUE sym_execute = rb_funcall(str_execute, rb_intern("to_sym"), 0);
|
982
|
+
VALUE str_pause = rb_str_new2("pause");
|
983
|
+
VALUE sym_pause = rb_funcall(str_pause, rb_intern("to_sym"), 0);
|
984
|
+
rb_funcall(diagram, rb_intern("start"), 0);
|
985
|
+
VALUE executing = rb_funcall(states, id_kakko, 1, sym_execute);
|
986
|
+
while(executing == Qtrue){
|
987
|
+
VALUE pausing = rb_funcall(states, id_kakko, 1, sym_pause);
|
988
|
+
if(pausing == Qfalse){
|
989
|
+
rb_funcall(mutex, rb_intern("lock"), 0);
|
990
|
+
rb_funcall(diagram, id_update, 0);
|
991
|
+
rb_funcall(mutex, rb_intern("unlock"), 0);
|
992
|
+
rb_funcall(cThread, rb_intern("pass"), 0);
|
993
|
+
VALUE is_finish = rb_funcall(diagram, rb_intern("finish?"), 0);
|
994
|
+
if(is_finish == Qtrue){ rb_funcall(states, rb_intern("[]="), 2, sym_execute, Qfalse); }
|
995
|
+
}
|
996
|
+
executing = rb_funcall(states, id_kakko, 1, sym_execute);
|
997
|
+
}
|
998
|
+
rb_funcall(diagram, rb_intern("stop"), 0);
|
999
|
+
return self;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
void Init_miyako_no_katana()
|
1003
|
+
{
|
1004
|
+
mSDL = rb_define_module("SDL");
|
1005
|
+
mMiyako = rb_define_module("Miyako");
|
1006
|
+
mScreen = rb_define_module_under(mMiyako, "Screen");
|
1007
|
+
mDiagram = rb_define_module_under(mMiyako, "Diagram");
|
1008
|
+
cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
|
1009
|
+
cGL = rb_define_module_under(mSDL, "GL");
|
1010
|
+
cFont = rb_define_class_under(mMiyako, "Font", rb_cObject);
|
1011
|
+
cThread = rb_define_class("Thread", rb_cObject);
|
1012
|
+
cSprite = rb_define_class_under(mMiyako, "Sprite", rb_cObject);
|
1013
|
+
cSpriteAnimation = rb_define_class_under(mMiyako, "SpriteAnimation", rb_cObject);
|
1014
|
+
cPlane = rb_define_class_under(mMiyako, "Plane", rb_cObject);
|
1015
|
+
cParts = rb_define_class_under(mMiyako, "Parts", rb_cObject);
|
1016
|
+
cMap = rb_define_class_under(mMiyako, "Map", rb_cObject);
|
1017
|
+
cMapLayer = rb_define_class_under(cMap, "MapLayer", rb_cObject);
|
1018
|
+
cFixedMap = rb_define_class_under(mMiyako, "FixedMap", rb_cObject);
|
1019
|
+
cFixedMapLayer = rb_define_class_under(cFixedMap, "FixedMapLayer", rb_cObject);
|
1020
|
+
cProcessor = rb_define_class_under(mDiagram, "Processor", rb_cObject);
|
1021
|
+
|
1022
|
+
id_update = rb_intern("update");
|
1023
|
+
id_kakko = rb_intern("[]");
|
1024
|
+
id_render = rb_intern("render");
|
1025
|
+
id_to_a = rb_intern("to_a");
|
1026
|
+
|
1027
|
+
zero = 0;
|
1028
|
+
nZero = INT2NUM(zero);
|
1029
|
+
one = 1;
|
1030
|
+
nOne = INT2NUM(one);
|
1031
|
+
|
1032
|
+
rb_define_module_function(mScreen, "update_tick", screen_update_tick, 0);
|
1033
|
+
rb_define_module_function(mScreen, "pre_render", screen_pre_render, 0);
|
1034
|
+
rb_define_module_function(mScreen, "render", screen_render, 0);
|
1035
|
+
rb_define_module_function(mScreen, "render_screen", screen_render_screen, 1);
|
1036
|
+
|
1037
|
+
rb_define_method(cSpriteAnimation, "update_animation", sa_update, 0);
|
1038
|
+
rb_define_method(cSpriteAnimation, "update_frame", sa_update_frame, 0);
|
1039
|
+
rb_define_method(cSpriteAnimation, "update_wait_counter", sa_update_wait_counter, 0);
|
1040
|
+
rb_define_method(cSpriteAnimation, "set_pat", sa_set_pat, 0);
|
1041
|
+
rb_define_method(cSpriteAnimation, "render", sa_render, 0);
|
1042
|
+
rb_define_method(cSpriteAnimation, "render_to", sa_render_to_sprite, 1);
|
1043
|
+
|
1044
|
+
rb_define_singleton_method(cSprite, "render_to", sprite_c_render_to_sprite, 2);
|
1045
|
+
rb_define_method(cSprite, "render", sprite_render, 0);
|
1046
|
+
rb_define_method(cSprite, "render_to", sprite_render_to_sprite, 1);
|
1047
|
+
|
1048
|
+
rb_define_method(cPlane, "render", plane_render, 0);
|
1049
|
+
rb_define_method(cPlane, "render_to", plane_render_to_sprite, 1);
|
1050
|
+
|
1051
|
+
rb_define_method(cParts, "render", parts_render, 0);
|
1052
|
+
rb_define_method(cParts, "render_to", parts_render_to_sprite, 1);
|
1053
|
+
|
1054
|
+
rb_define_method(cProcessor, "main_loop", processor_mainloop, 0);
|
1055
|
+
|
1056
|
+
rb_define_method(cMapLayer, "render", maplayer_render, 0);
|
1057
|
+
rb_define_method(cFixedMapLayer, "render", fixedmaplayer_render, 0);
|
1058
|
+
rb_define_method(cMap, "render", map_render, 0);
|
1059
|
+
rb_define_method(cFixedMap, "render", fixedmap_render, 0);
|
1060
|
+
rb_define_method(cMap, "render_to", map_render_to_sprite, 1);
|
1061
|
+
rb_define_method(cFixedMap, "render_to", fixedmap_render_to_sprite, 1);
|
1062
|
+
rb_define_method(cMapLayer, "render_to", maplayer_render_to_sprite, 1);
|
1063
|
+
rb_define_method(cFixedMapLayer, "render_to", fixedmaplayer_render_to_sprite, 1);
|
1064
|
+
|
1065
|
+
use_opengl = rb_gv_get("$miyako_use_opengl");
|
1066
|
+
|
1067
|
+
Init_miyako_bitmap();
|
1068
|
+
Init_miyako_transform();
|
1069
|
+
Init_miyako_hsv();
|
1070
|
+
Init_miyako_drawing();
|
1071
|
+
Init_miyako_layout();
|
1072
|
+
Init_miyako_collision();
|
1073
|
+
Init_miyako_basicdata();
|
1074
|
+
Init_miyako_sprite2();
|
1075
|
+
Init_miyako_font();
|
1076
|
+
Init_miyako_utility();
|
1077
|
+
Init_miyako_input_audio();
|
1078
|
+
}
|