ruby-miyako 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/miyako_no_katana.c CHANGED
@@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
20
  */
21
21
 
22
22
  /*
23
- =拡張ライブラリmiyako_no_katana
24
- Authors:: サイロス誠
23
+ =miyako_no_katana
24
+ Authors:: Cyross Makoto
25
25
  Version:: 2.0
26
26
  Copyright:: 2007-2008 Cyross Makoto
27
27
  License:: LGPL2.1
@@ -152,31 +152,31 @@ static VALUE sprite_get_rect(VALUE src, int *dst)
152
152
  }
153
153
 
154
154
  /*
155
- ===内部用レンダメソッド
156
155
  */
157
156
  static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
158
157
  {
158
+ int x, y, a1, a2;
159
+ MiyakoSize size;
160
+ Uint32 src_y, dst_y, src_x, dst_x, *psrc, *pdst;
159
161
  if(sb->ptr == db->ptr){ return; }
160
162
 
161
- MiyakoSize size;
162
163
  if(_miyako_init_rect(sb, db, &size) == 0) return;
163
164
 
164
165
  SDL_LockSurface(sb->surface);
165
166
  SDL_LockSurface(db->surface);
166
167
 
167
- int x, y;
168
168
  for(y = 0; y < size.h; y++)
169
169
  {
170
- Uint32 src_y = (sb->rect.y + y);
171
- Uint32 dst_y = (db->rect.y + sb->y + y);
172
- Uint32 src_x = sb->rect.x;
173
- Uint32 dst_x = db->rect.x + sb->x;
170
+ src_y = (sb->rect.y + y);
171
+ dst_y = (db->rect.y + sb->y + y);
172
+ src_x = sb->rect.x;
173
+ dst_x = db->rect.x + sb->x;
174
174
 
175
175
  if(src_y < 0 || dst_y < 0){ continue; }
176
176
  if(src_y >= sb->surface->h || dst_y >= db->surface->h){ break; }
177
177
 
178
- Uint32 *psrc = sb->ptr + src_y * sb->surface->w + src_x;
179
- Uint32 *pdst = db->ptr + dst_y * db->surface->w + dst_x;
178
+ psrc = sb->ptr + src_y * sb->surface->w + src_x;
179
+ pdst = db->ptr + dst_y * db->surface->w + dst_x;
180
180
  for(x = 0; x < size.w; x++)
181
181
  {
182
182
  if(src_x < 0 || dst_x < 0){ psrc++; pdst++; src_x++; dst_x++; continue; }
@@ -193,8 +193,8 @@ static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
193
193
  dst_x++;
194
194
  continue;
195
195
  }
196
- int a1 = sb->color.a + 1;
197
- int a2 = 256 - sb->color.a;
196
+ a1 = sb->color.a + 1;
197
+ a2 = 256 - sb->color.a;
198
198
  sb->color.r = (*psrc >> 16) & 0xff;
199
199
  sb->color.g = (*psrc >> 8) & 0xff;
200
200
  sb->color.b = (*psrc ) & 0xff;
@@ -217,8 +217,8 @@ static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
217
217
  dst_x++;
218
218
  continue;
219
219
  }
220
- int a1 = sb->color.a + 1;
221
- int a2 = 256 - sb->color.a;
220
+ a1 = sb->color.a + 1;
221
+ a2 = 256 - sb->color.a;
222
222
  sb->color.r = (*psrc & sb->fmt->Rmask) >> sb->fmt->Rshift;
223
223
  sb->color.g = (*psrc & sb->fmt->Gmask) >> sb->fmt->Gshift;
224
224
  sb->color.b = (*psrc & sb->fmt->Bmask) >> sb->fmt->Bshift;
@@ -242,7 +242,6 @@ static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
242
242
  }
243
243
 
244
244
  /*
245
- ===内部用レンダメソッド
246
245
  */
247
246
  static void render_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
248
247
  {
@@ -252,20 +251,20 @@ static void render_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
252
251
  }
253
252
 
254
253
  /*
255
- インスタンスの内容を画面に描画する
256
254
  */
257
255
  static VALUE sprite_b_render_xy(VALUE self, VALUE vx, VALUE vy)
258
256
  {
257
+ VALUE cls, *p_pos, x, y;
259
258
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
260
- VALUE cls = rb_obj_class(self);
259
+ cls = rb_obj_class(self);
261
260
  if(rb_funcall(cls, id_defined, ID2SYM(id_move_to)) == Qfalse ||
262
261
  rb_funcall(cls, id_defined, ID2SYM(id_pos)) == Qfalse ){
263
262
  rb_funcall(self, id_render, 0);
264
263
  return self;
265
264
  }
266
- VALUE *p_pos = RSTRUCT_PTR(_miyako_layout_pos(self));
267
- VALUE x = *(p_pos + 0);
268
- VALUE y = *(p_pos + 1);
265
+ p_pos = RSTRUCT_PTR(_miyako_layout_pos(self));
266
+ x = *(p_pos + 0);
267
+ y = *(p_pos + 1);
269
268
  _miyako_layout_move_to(self, vx, vy);
270
269
  rb_funcall(self, id_render, 0);
271
270
  _miyako_layout_move_to(self, x, y);
@@ -273,20 +272,20 @@ static VALUE sprite_b_render_xy(VALUE self, VALUE vx, VALUE vy)
273
272
  }
274
273
 
275
274
  /*
276
- インスタンスの内容を別のインスタンスに描画する
277
275
  */
278
276
  static VALUE sprite_b_render_xy_to_sprite(VALUE self, VALUE vdst, VALUE vx, VALUE vy)
279
277
  {
278
+ VALUE cls, *p_pos, x, y;
280
279
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
281
- VALUE cls = rb_obj_class(self);
280
+ cls = rb_obj_class(self);
282
281
  if(rb_funcall(cls, id_defined, ID2SYM(id_move_to)) == Qfalse ||
283
282
  rb_funcall(cls, id_defined, ID2SYM(id_pos)) == Qfalse ){
284
283
  rb_funcall(self, id_render_to, 1, vdst);
285
284
  return self;
286
285
  }
287
- VALUE *p_pos = RSTRUCT_PTR(_miyako_layout_pos(self));
288
- VALUE x = *(p_pos + 0);
289
- VALUE y = *(p_pos + 1);
286
+ p_pos = RSTRUCT_PTR(_miyako_layout_pos(self));
287
+ x = *(p_pos + 0);
288
+ y = *(p_pos + 1);
290
289
  _miyako_layout_move_to(self, vx, vy);
291
290
  rb_funcall(self, id_render_to, 1, vdst);
292
291
  _miyako_layout_move_to(self, x, y);
@@ -294,7 +293,6 @@ static VALUE sprite_b_render_xy_to_sprite(VALUE self, VALUE vdst, VALUE vx, VALU
294
293
  }
295
294
 
296
295
  /*
297
- インスタンスの内容を別のインスタンスに描画する
298
296
  */
299
297
  static VALUE sprite_c_render_to_sprite(VALUE self, VALUE vsrc, VALUE vdst)
300
298
  {
@@ -306,27 +304,28 @@ static VALUE sprite_c_render_to_sprite(VALUE self, VALUE vsrc, VALUE vdst)
306
304
  }
307
305
 
308
306
  /*
309
- インスタンスの内容を画面に描画する
310
307
  */
311
308
  static VALUE sprite_render(VALUE self)
312
309
  {
310
+ VALUE src_unit, dst_unit, *s_p, *d_p;
311
+ SDL_Surface *src, *dst;
312
+ SDL_Rect srect, drect;
313
+
313
314
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
314
315
 
315
- VALUE src_unit = rb_iv_get(self, "@unit");
316
- VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
316
+ src_unit = rb_iv_get(self, "@unit");
317
+ dst_unit = rb_iv_get(mScreen, "@@unit");
317
318
 
318
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
319
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
319
+ src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
320
+ dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
320
321
 
321
- SDL_Rect srect, drect;
322
-
323
- VALUE *s_p = RSTRUCT_PTR(src_unit);
322
+ s_p = RSTRUCT_PTR(src_unit);
324
323
  srect.x = NUM2INT(*(s_p + 1));
325
324
  srect.y = NUM2INT(*(s_p + 2));
326
325
  srect.w = NUM2INT(*(s_p + 3));
327
326
  srect.h = NUM2INT(*(s_p + 4));
328
327
 
329
- VALUE *d_p = RSTRUCT_PTR(dst_unit);
328
+ d_p = RSTRUCT_PTR(dst_unit);
330
329
  drect.x = NUM2INT(*(d_p + 1)) + NUM2INT(*(s_p + 5));
331
330
  drect.y = NUM2INT(*(d_p + 2)) + NUM2INT(*(s_p + 6));
332
331
  drect.w = NUM2INT(*(d_p + 3));
@@ -342,40 +341,41 @@ VALUE _miyako_sprite_render(VALUE sprite)
342
341
  }
343
342
 
344
343
  /*
345
- インスタンスの内容を別のインスタンスに描画する
346
344
  */
347
345
  static VALUE sprite_render_to_sprite(VALUE self, VALUE vdst)
348
346
  {
349
- if(rb_iv_get(self, str_visible) == Qfalse) return self;
350
347
  MiyakoBitmap src, dst;
351
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
348
+ SDL_Surface *scr;
349
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
350
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
352
351
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
353
352
  render_to_inner(&src, &dst);
354
353
  return self;
355
354
  }
356
355
 
357
356
  /*
358
- インスタンスの内容を画面に描画する
359
357
  */
360
358
  static VALUE sprite_render_xy(VALUE self, VALUE vx, VALUE vy)
361
359
  {
362
- if(rb_iv_get(self, str_visible) == Qfalse) return self;
360
+ VALUE src_unit, dst_unit, *s_p, *d_p;
361
+ SDL_Surface *src, *dst;
362
+ SDL_Rect srect, drect;
363
363
 
364
- VALUE src_unit = rb_iv_get(self, "@unit");
365
- VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
364
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
366
365
 
367
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
368
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
366
+ src_unit = rb_iv_get(self, "@unit");
367
+ dst_unit = rb_iv_get(mScreen, "@@unit");
369
368
 
370
- SDL_Rect srect, drect;
369
+ src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
370
+ dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
371
371
 
372
- VALUE *s_p = RSTRUCT_PTR(src_unit);
372
+ s_p = RSTRUCT_PTR(src_unit);
373
373
  srect.x = NUM2INT(*(s_p + 1));
374
374
  srect.y = NUM2INT(*(s_p + 2));
375
375
  srect.w = NUM2INT(*(s_p + 3));
376
376
  srect.h = NUM2INT(*(s_p + 4));
377
377
 
378
- VALUE *d_p = RSTRUCT_PTR(dst_unit);
378
+ d_p = RSTRUCT_PTR(dst_unit);
379
379
  drect.x = NUM2INT(*(d_p + 1)) + NUM2INT(vx);
380
380
  drect.y = NUM2INT(*(d_p + 2)) + NUM2INT(vy);
381
381
  drect.w = NUM2INT(*(d_p + 3));
@@ -391,14 +391,15 @@ VALUE _miyako_sprite_render_xy(VALUE sprite, VALUE x, VALUE y)
391
391
  }
392
392
 
393
393
  /*
394
- インスタンスの内容を別のインスタンスに描画する
395
394
  */
396
395
  static VALUE sprite_render_xy_to_sprite(VALUE self, VALUE vdst, VALUE vx, VALUE vy)
397
396
  {
397
+ MiyakoBitmap src, dst;
398
+ SDL_Surface *scr;
399
+
398
400
  VALUE visible = rb_iv_get(self, str_visible);
399
401
  if(visible == Qfalse) return self;
400
- MiyakoBitmap src, dst;
401
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
402
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
402
403
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
403
404
  src.x = NUM2INT(vx);
404
405
  src.y = NUM2INT(vy);
@@ -407,30 +408,31 @@ static VALUE sprite_render_xy_to_sprite(VALUE self, VALUE vdst, VALUE vx, VALUE
407
408
  }
408
409
 
409
410
  /*
410
- インスタンスの内容を画面に描画する
411
411
  */
412
412
  static VALUE sprite_render_rect(VALUE self, VALUE vrect)
413
413
  {
414
- if(rb_iv_get(self, str_visible) == Qfalse) return self;
415
-
414
+ VALUE src_unit, dst_unit, *s_p, *d_p;
415
+ SDL_Surface *src, *dst;
416
+ SDL_Rect srect, drect;
416
417
  int rect[4];
417
- sprite_get_rect(vrect, &(rect[0]));
418
418
 
419
- VALUE src_unit = rb_iv_get(self, "@unit");
420
- VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
419
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
421
420
 
422
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
423
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
421
+ sprite_get_rect(vrect, &(rect[0]));
424
422
 
425
- SDL_Rect srect, drect;
423
+ src_unit = rb_iv_get(self, "@unit");
424
+ dst_unit = rb_iv_get(mScreen, "@@unit");
426
425
 
427
- VALUE *s_p = RSTRUCT_PTR(src_unit);
426
+ src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
427
+ dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
428
+
429
+ s_p = RSTRUCT_PTR(src_unit);
428
430
  srect.x = NUM2INT(*(s_p + 1)) + rect[0];
429
431
  srect.y = NUM2INT(*(s_p + 2)) + rect[1];
430
432
  srect.w = rect[2];
431
433
  srect.h = rect[3];
432
434
 
433
- VALUE *d_p = RSTRUCT_PTR(dst_unit);
435
+ d_p = RSTRUCT_PTR(dst_unit);
434
436
  drect.x = NUM2INT(*(d_p + 1));
435
437
  drect.y = NUM2INT(*(d_p + 2));
436
438
  drect.w = NUM2INT(*(d_p + 3));
@@ -441,16 +443,17 @@ static VALUE sprite_render_rect(VALUE self, VALUE vrect)
441
443
  }
442
444
 
443
445
  /*
444
- インスタンスの内容を別のインスタンスに描画する
445
446
  */
446
447
  static VALUE sprite_render_rect_to_sprite(VALUE self, VALUE vdst, VALUE vrect)
447
448
  {
449
+ MiyakoBitmap src, dst;
450
+ SDL_Surface *scr;
451
+ int rect[4];
452
+
448
453
  VALUE visible = rb_iv_get(self, str_visible);
449
454
  if(visible == Qfalse) return self;
450
- int rect[4];
451
455
  sprite_get_rect(vrect, &(rect[0]));
452
- MiyakoBitmap src, dst;
453
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
456
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
454
457
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
455
458
  src.rect.x += rect[0];
456
459
  src.rect.y += rect[1];
@@ -461,29 +464,30 @@ static VALUE sprite_render_rect_to_sprite(VALUE self, VALUE vdst, VALUE vrect)
461
464
  }
462
465
 
463
466
  /*
464
- インスタンスの内容を画面に描画する
465
467
  */
466
468
  static VALUE sprite_render_rect2(VALUE self, VALUE vrect)
467
469
  {
470
+ VALUE src_unit, dst_unit, *d_p;
471
+ SDL_Surface *src, *dst;
472
+ SDL_Rect srect, drect;
473
+ int rect[4];
474
+
468
475
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
469
476
 
470
- int rect[4];
471
477
  sprite_get_rect(vrect, &(rect[0]));
472
478
 
473
- VALUE src_unit = rb_iv_get(self, "@unit");
474
- VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
475
-
476
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
477
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
479
+ src_unit = rb_iv_get(self, "@unit");
480
+ dst_unit = rb_iv_get(mScreen, "@@unit");
478
481
 
479
- SDL_Rect srect, drect;
482
+ src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
483
+ dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
480
484
 
481
485
  srect.x = rect[0];
482
486
  srect.y = rect[1];
483
487
  srect.w = rect[2];
484
488
  srect.h = rect[3];
485
489
 
486
- VALUE *d_p = RSTRUCT_PTR(dst_unit);
490
+ d_p = RSTRUCT_PTR(dst_unit);
487
491
  drect.x = NUM2INT(*(d_p + 1));
488
492
  drect.y = NUM2INT(*(d_p + 2));
489
493
  drect.w = NUM2INT(*(d_p + 3));
@@ -494,16 +498,17 @@ static VALUE sprite_render_rect2(VALUE self, VALUE vrect)
494
498
  }
495
499
 
496
500
  /*
497
- インスタンスの内容を別のインスタンスに描画する
498
501
  */
499
502
  static VALUE sprite_render_rect2_to_sprite(VALUE self, VALUE vdst, VALUE vrect)
500
503
  {
504
+ MiyakoBitmap src, dst;
505
+ SDL_Surface *scr;
506
+ int rect[4];
507
+
501
508
  VALUE visible = rb_iv_get(self, str_visible);
502
509
  if(visible == Qfalse) return self;
503
- int rect[4];
504
510
  sprite_get_rect(vrect, &(rect[0]));
505
- MiyakoBitmap src, dst;
506
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
511
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
507
512
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
508
513
  src.rect.x = rect[0];
509
514
  src.rect.y = rect[1];
@@ -514,30 +519,31 @@ static VALUE sprite_render_rect2_to_sprite(VALUE self, VALUE vdst, VALUE vrect)
514
519
  }
515
520
 
516
521
  /*
517
- インスタンスの内容を画面に描画する
518
522
  */
519
523
  static VALUE sprite_render_rect_xy(VALUE self, VALUE vrect, VALUE vx, VALUE vy)
520
524
  {
525
+ VALUE src_unit, dst_unit, *s_p, *d_p;
526
+ SDL_Surface *src, *dst;
527
+ SDL_Rect srect, drect;
528
+ int rect[4];
529
+
521
530
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
522
531
 
523
- int rect[4];
524
532
  sprite_get_rect(vrect, &(rect[0]));
525
533
 
526
- VALUE src_unit = rb_iv_get(self, "@unit");
527
- VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
528
-
529
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
530
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
534
+ src_unit = rb_iv_get(self, "@unit");
535
+ dst_unit = rb_iv_get(mScreen, "@@unit");
531
536
 
532
- SDL_Rect srect, drect;
537
+ src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
538
+ dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
533
539
 
534
- VALUE *s_p = RSTRUCT_PTR(src_unit);
540
+ s_p = RSTRUCT_PTR(src_unit);
535
541
  srect.x = NUM2INT(*(s_p + 1)) + rect[0];
536
542
  srect.y = NUM2INT(*(s_p + 2)) + rect[1];
537
543
  srect.w = rect[2];
538
544
  srect.h = rect[3];
539
545
 
540
- VALUE *d_p = RSTRUCT_PTR(dst_unit);
546
+ d_p = RSTRUCT_PTR(dst_unit);
541
547
  drect.x = NUM2INT(*(d_p + 1)) + NUM2INT(vx);
542
548
  drect.y = NUM2INT(*(d_p + 2)) + NUM2INT(vy);
543
549
  drect.w = NUM2INT(*(d_p + 3));
@@ -548,16 +554,16 @@ static VALUE sprite_render_rect_xy(VALUE self, VALUE vrect, VALUE vx, VALUE vy)
548
554
  }
549
555
 
550
556
  /*
551
- インスタンスの内容を別のインスタンスに描画する
552
557
  */
553
558
  static VALUE sprite_render_rect_xy_to_sprite(VALUE self, VALUE vdst, VALUE vrect, VALUE vx, VALUE vy)
554
559
  {
560
+ MiyakoBitmap src, dst;
561
+ SDL_Surface *scr;
562
+ int rect[4];
555
563
  VALUE visible = rb_iv_get(self, str_visible);
556
564
  if(visible == Qfalse) return self;
557
- int rect[4];
558
565
  sprite_get_rect(vrect, &(rect[0]));
559
- MiyakoBitmap src, dst;
560
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
566
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
561
567
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
562
568
  src.rect.x += rect[0];
563
569
  src.rect.y += rect[1];
@@ -570,29 +576,30 @@ static VALUE sprite_render_rect_xy_to_sprite(VALUE self, VALUE vdst, VALUE vrect
570
576
  }
571
577
 
572
578
  /*
573
- インスタンスの内容を画面に描画する
574
579
  */
575
580
  static VALUE sprite_render_rect2_xy(VALUE self, VALUE vrect, VALUE vx, VALUE vy)
576
581
  {
582
+ VALUE src_unit, dst_unit, *d_p;
583
+ SDL_Surface *src, *dst;
584
+ SDL_Rect srect, drect;
585
+ int rect[4];
586
+
577
587
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
578
588
 
579
- int rect[4];
580
589
  sprite_get_rect(vrect, &(rect[0]));
581
590
 
582
- VALUE src_unit = rb_iv_get(self, "@unit");
583
- VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
591
+ src_unit = rb_iv_get(self, "@unit");
592
+ dst_unit = rb_iv_get(mScreen, "@@unit");
584
593
 
585
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
586
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
587
-
588
- SDL_Rect srect, drect;
594
+ src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
595
+ dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
589
596
 
590
597
  srect.x = rect[0];
591
598
  srect.y = rect[1];
592
599
  srect.w = rect[2];
593
600
  srect.h = rect[3];
594
601
 
595
- VALUE *d_p = RSTRUCT_PTR(dst_unit);
602
+ d_p = RSTRUCT_PTR(dst_unit);
596
603
  drect.x = NUM2INT(*(d_p + 1)) + NUM2INT(vx);
597
604
  drect.y = NUM2INT(*(d_p + 2)) + NUM2INT(vy);
598
605
  drect.w = NUM2INT(*(d_p + 3));
@@ -603,16 +610,17 @@ static VALUE sprite_render_rect2_xy(VALUE self, VALUE vrect, VALUE vx, VALUE vy)
603
610
  }
604
611
 
605
612
  /*
606
- インスタンスの内容を別のインスタンスに描画する
607
613
  */
608
614
  static VALUE sprite_render_rect2_xy_to_sprite(VALUE self, VALUE vdst, VALUE vrect, VALUE vx, VALUE vy)
609
615
  {
616
+ MiyakoBitmap src, dst;
617
+ SDL_Surface *scr;
618
+ int rect[4];
619
+
610
620
  VALUE visible = rb_iv_get(self, str_visible);
611
621
  if(visible == Qfalse) return self;
612
- int rect[4];
613
622
  sprite_get_rect(vrect, &(rect[0]));
614
- MiyakoBitmap src, dst;
615
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
623
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
616
624
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
617
625
  src.rect.x = rect[0];
618
626
  src.rect.y = rect[1];
@@ -665,7 +673,6 @@ void _miyako_screen_pre_render()
665
673
  }
666
674
 
667
675
  /*
668
- 画面を更新する
669
676
  */
670
677
  static VALUE screen_render(VALUE self)
671
678
  {
@@ -683,11 +690,12 @@ static VALUE screen_render(VALUE self)
683
690
  int fps_max = NUM2INT(rb_const_get(mScreen, rb_intern("FpsMax")));
684
691
  VALUE sans_serif = rb_funcall(cFont, rb_intern("sans_serif"), 0);
685
692
  VALUE fps_sprite = Qnil;
693
+ VALUE fps_str;
686
694
 
687
695
  if(interval == 0){ interval = 1; }
688
696
 
689
697
  sprintf(str, "%d fps", fps_max / interval);
690
- VALUE fps_str = rb_str_new2((const char *)str);
698
+ fps_str = rb_str_new2((const char *)str);
691
699
 
692
700
  fps_sprite = rb_funcall(fps_str, rb_intern("to_sprite"), 1, sans_serif);
693
701
  sprite_render(fps_sprite);
@@ -711,7 +719,6 @@ void _miyako_screen_render()
711
719
  }
712
720
 
713
721
  /*
714
- インスタンスの内容を画面に描画する
715
722
  */
716
723
  static VALUE screen_render_screen(VALUE self, VALUE vsrc)
717
724
  {
@@ -792,10 +799,15 @@ static VALUE anim_m_update(VALUE self)
792
799
  }
793
800
 
794
801
  /*
795
- ===マップレイヤー転送インナーメソッド
796
802
  */
797
803
  static void maplayer_render_inner(VALUE self, MiyakoBitmap *dst)
798
804
  {
805
+ int dx, mx, dy, my, bx, by, code;
806
+ int x, y, idx1, idx2;
807
+ MiyakoBitmap src;
808
+ SDL_Surface *scr;
809
+ VALUE mapdat2;
810
+
799
811
  int cw = NUM2INT(rb_iv_get(self, "@cw"));
800
812
  int ch = NUM2INT(rb_iv_get(self, "@ch"));
801
813
  int ow = NUM2INT(rb_iv_get(self, "@ow"));
@@ -826,24 +838,22 @@ static void maplayer_render_inner(VALUE self, MiyakoBitmap *dst)
826
838
  if(pos_x >= real_size_w){ pos_x %= real_size_w; }
827
839
  if(pos_y >= real_size_h){ pos_y %= real_size_h; }
828
840
 
829
- int dx = pos_x / mc_chip_size_w;
830
- int mx = pos_x % mc_chip_size_w;
831
- int dy = pos_y / mc_chip_size_h;
832
- int my = pos_y % mc_chip_size_h;
841
+ dx = pos_x / mc_chip_size_w;
842
+ mx = pos_x % mc_chip_size_w;
843
+ dy = pos_y / mc_chip_size_h;
844
+ my = pos_y % mc_chip_size_h;
833
845
 
834
- MiyakoBitmap src;
835
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
846
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
836
847
 
837
- int bx = dst->rect.x;
838
- int by = dst->rect.y;
848
+ bx = dst->rect.x;
849
+ by = dst->rect.y;
839
850
 
840
- int x, y, idx1, idx2;
841
851
  for(y = 0; y < ch; y++){
842
852
  idx1 = (y + dy) % size_h;
843
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
853
+ mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
844
854
  for(x = 0; x < cw; x++){
845
855
  idx2 = (x + dx) % size_w;
846
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
856
+ code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
847
857
  if(code == -1){ continue; }
848
858
  _miyako_setup_unit(
849
859
  rb_funcall(*(RARRAY_PTR(munits) + code),
@@ -858,10 +868,12 @@ static void maplayer_render_inner(VALUE self, MiyakoBitmap *dst)
858
868
  }
859
869
 
860
870
  /*
861
- ===固定マップレイヤー転送インナーメソッド
862
871
  */
863
872
  static void fixedmaplayer_render_inner(VALUE self, MiyakoBitmap *dst)
864
873
  {
874
+ int code;
875
+ VALUE mapdat2;
876
+
865
877
  int cw = NUM2INT(rb_iv_get(self, "@cw"));
866
878
  int ch = NUM2INT(rb_iv_get(self, "@ch"));
867
879
  int ow = NUM2INT(rb_iv_get(self, "@ow"));
@@ -887,10 +899,10 @@ static void fixedmaplayer_render_inner(VALUE self, MiyakoBitmap *dst)
887
899
  int x, y, idx1, idx2;
888
900
  for(y = 0; y < ch; y++){
889
901
  idx1 = y % size_h;
890
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
902
+ mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
891
903
  for(x = 0; x < cw; x++){
892
904
  idx2 = x % size_w;
893
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
905
+ code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
894
906
  if(code == -1){ continue; }
895
907
  _miyako_setup_unit(rb_funcall(*(RARRAY_PTR(munits) + code), rb_intern("to_unit"), 0),
896
908
  scr, &src, INT2NUM(pos_x + x * ow), INT2NUM(pos_y + y * oh), 0);
@@ -902,10 +914,15 @@ static void fixedmaplayer_render_inner(VALUE self, MiyakoBitmap *dst)
902
914
  }
903
915
 
904
916
  /*
905
- ===マップレイヤー転送インナーメソッド
906
917
  */
907
918
  static void maplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
908
919
  {
920
+ int dx, mx, dy, my, bx, by, code;
921
+ int x, y, idx1, idx2;
922
+ MiyakoBitmap src;
923
+ SDL_Surface *scr;
924
+ VALUE mapdat2;
925
+
909
926
  int cw = NUM2INT(rb_iv_get(self, "@cw"));
910
927
  int ch = NUM2INT(rb_iv_get(self, "@ch"));
911
928
  int ow = NUM2INT(rb_iv_get(self, "@ow"));
@@ -936,24 +953,22 @@ static void maplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
936
953
  if(pos_x >= real_size_w){ pos_x %= real_size_w; }
937
954
  if(pos_y >= real_size_h){ pos_y %= real_size_h; }
938
955
 
939
- int dx = pos_x / mc_chip_size_w;
940
- int mx = pos_x % mc_chip_size_w;
941
- int dy = pos_y / mc_chip_size_h;
942
- int my = pos_y % mc_chip_size_h;
956
+ dx = pos_x / mc_chip_size_w;
957
+ mx = pos_x % mc_chip_size_w;
958
+ dy = pos_y / mc_chip_size_h;
959
+ my = pos_y % mc_chip_size_h;
943
960
 
944
- MiyakoBitmap src;
945
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
961
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
946
962
 
947
- int bx = dst->rect.x;
948
- int by = dst->rect.y;
963
+ bx = dst->rect.x;
964
+ by = dst->rect.y;
949
965
 
950
- int x, y, idx1, idx2;
951
966
  for(y = 0; y < ch; y++){
952
967
  idx1 = (y + dy) % size_h;
953
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
968
+ mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
954
969
  for(x = 0; x < cw; x++){
955
970
  idx2 = (x + dx) % size_w;
956
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
971
+ code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
957
972
  if(code == -1){ continue; }
958
973
  _miyako_setup_unit(rb_funcall(*(RARRAY_PTR(munits) + code), rb_intern("to_unit"), 0),
959
974
  scr, &src, INT2NUM(x * ow - mx), INT2NUM(y * oh - my), 0);
@@ -965,10 +980,12 @@ static void maplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
965
980
  }
966
981
 
967
982
  /*
968
- ===固定マップレイヤー転送インナーメソッド
969
983
  */
970
984
  static void fixedmaplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
971
985
  {
986
+ int code;
987
+ VALUE mapdat2;
988
+
972
989
  int cw = NUM2INT(rb_iv_get(self, "@cw"));
973
990
  int ch = NUM2INT(rb_iv_get(self, "@ch"));
974
991
  int ow = NUM2INT(rb_iv_get(self, "@ow"));
@@ -994,10 +1011,10 @@ static void fixedmaplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
994
1011
  int x, y, idx1, idx2;
995
1012
  for(y = 0; y < ch; y++){
996
1013
  idx1 = y % size_h;
997
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
1014
+ mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
998
1015
  for(x = 0; x < cw; x++){
999
1016
  idx2 = x % size_w;
1000
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
1017
+ code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
1001
1018
  if(code == -1){ continue; }
1002
1019
  _miyako_setup_unit(rb_funcall(*(RARRAY_PTR(munits) + code), rb_intern("to_unit"), 0),
1003
1020
  scr, &src, INT2NUM(pos_x + x * ow), INT2NUM(pos_y + y * oh), 0);
@@ -1009,73 +1026,74 @@ static void fixedmaplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
1009
1026
  }
1010
1027
 
1011
1028
  /*
1012
- マップレイヤーを画面に描画する
1013
1029
  */
1014
1030
  static VALUE maplayer_render(VALUE self)
1015
1031
  {
1032
+ MiyakoBitmap dst;
1033
+ SDL_Surface *scr;
1016
1034
  VALUE visible = rb_iv_get(self, str_visible);
1017
1035
  if(visible == Qfalse) return self;
1018
- MiyakoBitmap dst;
1019
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1036
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1020
1037
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
1021
1038
  maplayer_render_inner(self, &dst);
1022
1039
  return self;
1023
1040
  }
1024
1041
 
1025
1042
  /*
1026
- マップレイヤーを画面に描画する
1027
1043
  */
1028
1044
  static VALUE fixedmaplayer_render(VALUE self)
1029
1045
  {
1046
+ MiyakoBitmap dst;
1047
+ SDL_Surface *scr;
1030
1048
  VALUE visible = rb_iv_get(self, str_visible);
1031
1049
  if(visible == Qfalse) return self;
1032
- MiyakoBitmap dst;
1033
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1050
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1034
1051
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
1035
1052
  fixedmaplayer_render_inner(self, &dst);
1036
1053
  return self;
1037
1054
  }
1038
1055
 
1039
1056
  /*
1040
- マップレイヤーを画像に転送する
1041
1057
  */
1042
1058
  static VALUE maplayer_render_to_sprite(VALUE self, VALUE vdst)
1043
1059
  {
1060
+ MiyakoBitmap dst;
1061
+ SDL_Surface *scr;
1044
1062
  VALUE visible = rb_iv_get(self, str_visible);
1045
1063
  if(visible == Qfalse) return self;
1046
- MiyakoBitmap dst;
1047
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1064
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1048
1065
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
1049
1066
  maplayer_render_to_inner(self, &dst);
1050
1067
  return self;
1051
1068
  }
1052
1069
 
1053
1070
  /*
1054
- マップレイヤーを画像に転送する
1055
1071
  */
1056
1072
  static VALUE fixedmaplayer_render_to_sprite(VALUE self, VALUE vdst)
1057
1073
  {
1074
+ MiyakoBitmap dst;
1075
+ SDL_Surface *scr;
1058
1076
  VALUE visible = rb_iv_get(self, str_visible);
1059
1077
  if(visible == Qfalse) return self;
1060
- MiyakoBitmap dst;
1061
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1078
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1062
1079
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
1063
1080
  maplayer_render_inner(self, &dst);
1064
1081
  return self;
1065
1082
  }
1066
1083
 
1067
1084
  /*
1068
- マップを画面に描画する
1069
1085
  */
1070
1086
  static VALUE map_render(VALUE self)
1071
1087
  {
1088
+ int i;
1089
+ MiyakoBitmap dst;
1090
+ SDL_Surface *scr;
1091
+ VALUE map_layers;
1072
1092
  VALUE visible = rb_iv_get(self, str_visible);
1073
1093
  if(visible == Qfalse) return self;
1074
- MiyakoBitmap dst;
1075
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1094
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1076
1095
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
1077
- VALUE map_layers = rb_iv_get(self, "@map_layers");
1078
- int i;
1096
+ map_layers = rb_iv_get(self, "@map_layers");
1079
1097
  for(i=0; i<RARRAY_LEN(map_layers); i++){
1080
1098
  maplayer_render_inner(*(RARRAY_PTR(map_layers) + i), &dst);
1081
1099
  }
@@ -1084,17 +1102,18 @@ static VALUE map_render(VALUE self)
1084
1102
  }
1085
1103
 
1086
1104
  /*
1087
- マップを画面に描画する
1088
1105
  */
1089
1106
  static VALUE fixedmap_render(VALUE self)
1090
1107
  {
1108
+ int i;
1109
+ MiyakoBitmap dst;
1110
+ SDL_Surface *scr;
1111
+ VALUE map_layers;
1091
1112
  VALUE visible = rb_iv_get(self, str_visible);
1092
1113
  if(visible == Qfalse) return self;
1093
- MiyakoBitmap dst;
1094
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1114
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1095
1115
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
1096
- VALUE map_layers = rb_iv_get(self, "@map_layers");
1097
- int i;
1116
+ map_layers = rb_iv_get(self, "@map_layers");
1098
1117
  for(i=0; i<RARRAY_LEN(map_layers); i++){
1099
1118
  fixedmaplayer_render_inner(*(RARRAY_PTR(map_layers) + i), &dst);
1100
1119
  }
@@ -1103,18 +1122,19 @@ static VALUE fixedmap_render(VALUE self)
1103
1122
  }
1104
1123
 
1105
1124
  /*
1106
- マップを画像に描画する
1107
1125
  */
1108
1126
  static VALUE map_render_to_sprite(VALUE self, VALUE vdst)
1109
1127
  {
1128
+ int i;
1129
+ MiyakoBitmap dst;
1130
+ SDL_Surface *scr;
1131
+ VALUE map_layers;
1110
1132
  VALUE visible = rb_iv_get(self, str_visible);
1111
1133
  if(visible == Qfalse) return self;
1112
- MiyakoBitmap dst;
1113
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1134
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1114
1135
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
1115
1136
 
1116
- VALUE map_layers = rb_iv_get(self, "@map_layers");
1117
- int i;
1137
+ map_layers = rb_iv_get(self, "@map_layers");
1118
1138
  for(i=0; i<RARRAY_LEN(map_layers); i++){
1119
1139
  maplayer_render_to_inner(*(RARRAY_PTR(map_layers) + i), &dst);
1120
1140
  }
@@ -1123,18 +1143,19 @@ static VALUE map_render_to_sprite(VALUE self, VALUE vdst)
1123
1143
  }
1124
1144
 
1125
1145
  /*
1126
- マップを画像に描画する
1127
1146
  */
1128
1147
  static VALUE fixedmap_render_to_sprite(VALUE self, VALUE vdst)
1129
1148
  {
1149
+ int i;
1150
+ MiyakoBitmap dst;
1151
+ SDL_Surface *scr;
1152
+ VALUE map_layers;
1130
1153
  VALUE visible = rb_iv_get(self, str_visible);
1131
1154
  if(visible == Qfalse) return self;
1132
- MiyakoBitmap dst;
1133
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1155
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1134
1156
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
1135
1157
 
1136
- VALUE map_layers = rb_iv_get(self, "@map_layers");
1137
- int i;
1158
+ map_layers = rb_iv_get(self, "@map_layers");
1138
1159
  for(i=0; i<RARRAY_LEN(map_layers); i++){
1139
1160
  fixedmaplayer_render_to_inner(*(RARRAY_PTR(map_layers) + i), &dst);
1140
1161
  }
@@ -1159,6 +1180,8 @@ static VALUE sa_set_pat(VALUE self)
1159
1180
  */
1160
1181
  static VALUE sa_update_frame(VALUE self)
1161
1182
  {
1183
+ VALUE num, loop, plist, waits;
1184
+ int pnum, pats;
1162
1185
  int cnt = NUM2INT(rb_iv_get(self, "@cnt"));
1163
1186
 
1164
1187
  if(cnt > 0){
@@ -1167,11 +1190,11 @@ static VALUE sa_update_frame(VALUE self)
1167
1190
  return Qfalse;
1168
1191
  }
1169
1192
 
1170
- VALUE num = rb_iv_get(self, "@pnum");
1171
- VALUE loop = rb_iv_get(self, "@loop");
1193
+ num = rb_iv_get(self, "@pnum");
1194
+ loop = rb_iv_get(self, "@loop");
1172
1195
 
1173
- int pnum = NUM2INT(num);
1174
- int pats = NUM2INT(rb_iv_get(self, "@pats"));
1196
+ pnum = NUM2INT(num);
1197
+ pats = NUM2INT(rb_iv_get(self, "@pats"));
1175
1198
  pnum = (pnum + 1) % pats;
1176
1199
 
1177
1200
  rb_iv_set(self, "@pnum", INT2NUM(pnum));
@@ -1182,8 +1205,8 @@ static VALUE sa_update_frame(VALUE self)
1182
1205
  }
1183
1206
 
1184
1207
  sa_set_pat(self);
1185
- VALUE plist = rb_iv_get(self, "@plist");
1186
- VALUE waits = rb_iv_get(self, "@waits");
1208
+ plist = rb_iv_get(self, "@plist");
1209
+ waits = rb_iv_get(self, "@waits");
1187
1210
  rb_iv_set(self, "@cnt", *(RARRAY_PTR(waits) + NUM2INT(*(RARRAY_PTR(plist) + pnum))));
1188
1211
 
1189
1212
  return Qtrue;
@@ -1194,16 +1217,18 @@ static VALUE sa_update_frame(VALUE self)
1194
1217
  */
1195
1218
  static VALUE sa_update_wait_counter(VALUE self)
1196
1219
  {
1220
+ VALUE num, loop, plist, waits;
1221
+ int pnum, pats;
1197
1222
  VALUE cnt = rb_iv_get(self, "@cnt");
1198
1223
  VALUE waiting = rb_funcall(cnt, rb_intern("waiting?"), 0);
1199
1224
 
1200
1225
  if(waiting == Qtrue) return Qfalse;
1201
1226
 
1202
- VALUE num = rb_iv_get(self, "@pnum");
1203
- VALUE loop = rb_iv_get(self, "@loop");
1227
+ num = rb_iv_get(self, "@pnum");
1228
+ loop = rb_iv_get(self, "@loop");
1204
1229
 
1205
- int pnum = NUM2INT(num);
1206
- int pats = NUM2INT(rb_iv_get(self, "@pats"));
1230
+ pnum = NUM2INT(num);
1231
+ pats = NUM2INT(rb_iv_get(self, "@pats"));
1207
1232
  pnum = (pnum + 1) % pats;
1208
1233
 
1209
1234
  rb_iv_set(self, "@pnum", INT2NUM(pnum));
@@ -1214,8 +1239,8 @@ static VALUE sa_update_wait_counter(VALUE self)
1214
1239
  }
1215
1240
 
1216
1241
  sa_set_pat(self);
1217
- VALUE plist = rb_iv_get(self, "@plist");
1218
- VALUE waits = rb_iv_get(self, "@waits");
1242
+ plist = rb_iv_get(self, "@plist");
1243
+ waits = rb_iv_get(self, "@waits");
1219
1244
  cnt = *(RARRAY_PTR(waits) + NUM2INT(*(RARRAY_PTR(plist) + pnum)));
1220
1245
  rb_iv_set(self, "@cnt", cnt);
1221
1246
  rb_funcall(cnt, rb_intern("start"), 0);
@@ -1240,35 +1265,38 @@ static VALUE sa_update(VALUE self)
1240
1265
  }
1241
1266
 
1242
1267
  /*
1243
- アニメーションの現在の画像を画面に描画する
1244
1268
  */
1245
1269
  static VALUE sa_render(VALUE self)
1246
1270
  {
1271
+ VALUE vsrc, *runit, polist, dir, *move_off, tmp_oxy, tmp_x, tmp_y;
1272
+ int num, pos_off, didx;
1273
+ MiyakoBitmap src, dst;
1274
+ SDL_Surface *scr;
1275
+
1247
1276
  VALUE visible = rb_iv_get(self, str_visible);
1248
1277
  if(visible == Qfalse) return self;
1249
- VALUE vsrc = rb_iv_get(self, "@now");
1250
- VALUE *runit = RSTRUCT_PTR(vsrc);
1251
- VALUE polist = rb_iv_get(self, "@pos_offset");
1252
- VALUE dir = rb_iv_get(self, "@dir");
1278
+ vsrc = rb_iv_get(self, "@now");
1279
+ runit = RSTRUCT_PTR(vsrc);
1280
+ polist = rb_iv_get(self, "@pos_offset");
1281
+ dir = rb_iv_get(self, "@dir");
1253
1282
 
1254
- int num = NUM2INT(rb_iv_get(self, "@pnum"));
1283
+ num = NUM2INT(rb_iv_get(self, "@pnum"));
1255
1284
 
1256
- VALUE *move_off = RARRAY_PTR(rb_funcall(*(RARRAY_PTR(rb_iv_get(self, "@move_offset")) + num), id_to_a, 0));
1285
+ move_off = RARRAY_PTR(rb_funcall(*(RARRAY_PTR(rb_iv_get(self, "@move_offset")) + num), id_to_a, 0));
1257
1286
 
1258
- int pos_off = NUM2INT(*(RARRAY_PTR(polist) + num));
1287
+ pos_off = NUM2INT(*(RARRAY_PTR(polist) + num));
1259
1288
 
1260
- int didx = (rb_to_id(dir) == rb_intern("h") ? 2 : 1);
1289
+ didx = (rb_to_id(dir) == rb_intern("h") ? 2 : 1);
1261
1290
 
1262
- VALUE tmp_oxy = *(runit + didx);
1263
- VALUE tmp_x = *(runit + 5);
1264
- VALUE tmp_y = *(runit + 6);
1291
+ tmp_oxy = *(runit + didx);
1292
+ tmp_x = *(runit + 5);
1293
+ tmp_y = *(runit + 6);
1265
1294
 
1266
1295
  *(runit + didx) = INT2NUM(NUM2INT(tmp_oxy) - pos_off);
1267
1296
  *(runit + 5) = INT2NUM(NUM2INT(tmp_x) + NUM2INT(*(move_off+0)));
1268
1297
  *(runit + 6) = INT2NUM(NUM2INT(tmp_y) + NUM2INT(*(move_off+1)));
1269
1298
 
1270
- MiyakoBitmap src, dst;
1271
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1299
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1272
1300
  _miyako_setup_unit_2(vsrc, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
1273
1301
  render_inner(&src, &dst);
1274
1302
 
@@ -1280,36 +1308,39 @@ static VALUE sa_render(VALUE self)
1280
1308
  }
1281
1309
 
1282
1310
  /*
1283
- アニメーションの現在の画像を画像に描画する
1284
1311
  */
1285
1312
  static VALUE sa_render_to_sprite(VALUE self, VALUE vdst)
1286
1313
  {
1314
+ VALUE vsrc, *runit, polist, dir, molist, move_off, tmp_oxy, tmp_x, tmp_y;
1315
+ int num, pos_off, didx;
1316
+ MiyakoBitmap src, dst;
1317
+ SDL_Surface *scr;
1318
+
1287
1319
  VALUE visible = rb_iv_get(self, str_visible);
1288
1320
  if(visible == Qfalse) return self;
1289
- VALUE vsrc = rb_iv_get(self, "@now");
1290
- VALUE *runit = RSTRUCT_PTR(vsrc);
1291
- VALUE polist = rb_iv_get(self, "@pos_offset");
1292
- VALUE dir = rb_iv_get(self, "@dir");
1321
+ vsrc = rb_iv_get(self, "@now");
1322
+ runit = RSTRUCT_PTR(vsrc);
1323
+ polist = rb_iv_get(self, "@pos_offset");
1324
+ dir = rb_iv_get(self, "@dir");
1293
1325
 
1294
- int num = NUM2INT(rb_iv_get(self, "@pnum"));
1326
+ num = NUM2INT(rb_iv_get(self, "@pnum"));
1295
1327
 
1296
- int pos_off = NUM2INT(*(RARRAY_PTR(polist) + num));
1328
+ pos_off = NUM2INT(*(RARRAY_PTR(polist) + num));
1297
1329
 
1298
- VALUE molist = rb_iv_get(self, "@move_offset");
1299
- VALUE move_off = *(RARRAY_PTR(molist) + num);
1330
+ molist = rb_iv_get(self, "@move_offset");
1331
+ move_off = *(RARRAY_PTR(molist) + num);
1300
1332
 
1301
- int didx = (rb_to_id(dir) == rb_intern("h") ? 3 : 2);
1333
+ didx = (rb_to_id(dir) == rb_intern("h") ? 3 : 2);
1302
1334
 
1303
- VALUE tmp_oxy = *(runit + didx);
1304
- VALUE tmp_x = *(runit + 5);
1305
- VALUE tmp_y = *(runit + 6);
1335
+ tmp_oxy = *(runit + didx);
1336
+ tmp_x = *(runit + 5);
1337
+ tmp_y = *(runit + 6);
1306
1338
 
1307
1339
  *(runit + didx) = INT2NUM(NUM2INT(tmp_oxy) - pos_off);
1308
1340
  *(runit + 5) = INT2NUM(NUM2INT(tmp_x) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nZero)));
1309
1341
  *(runit + 6) = INT2NUM(NUM2INT(tmp_y) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nOne )));
1310
1342
 
1311
- MiyakoBitmap src, dst;
1312
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1343
+ scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1313
1344
  _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
1314
1345
  render_to_inner(&src, &dst);
1315
1346
 
@@ -1321,31 +1352,32 @@ static VALUE sa_render_to_sprite(VALUE self, VALUE vdst)
1321
1352
  }
1322
1353
 
1323
1354
  /*
1324
- プレーンを画面に描画する
1325
1355
  */
1326
1356
  static VALUE plane_render(VALUE self)
1327
1357
  {
1358
+ VALUE sprite, pos, size, osize, vx, vy;
1359
+ int x, y, w, h, pos_x, pos_y, ow, oh;
1360
+
1328
1361
  VALUE visible = rb_iv_get(self, str_visible);
1329
1362
  if(visible == Qfalse) return self;
1330
- VALUE sprite = rb_iv_get(self, "@sprite");
1331
-
1332
- VALUE pos = rb_iv_get(self, "@pos");
1333
- VALUE size = rb_iv_get(self, "@size");
1334
- VALUE osize = rb_funcall(sprite, rb_intern("layout_size"), 0);
1335
- int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
1336
- int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
1337
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
1338
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
1339
- int ow = NUM2INT(*(RSTRUCT_PTR(osize) + 0));
1340
- int oh = NUM2INT(*(RSTRUCT_PTR(osize) + 1));
1363
+ sprite = rb_iv_get(self, "@sprite");
1364
+
1365
+ pos = rb_iv_get(self, "@pos");
1366
+ size = rb_iv_get(self, "@size");
1367
+ osize = rb_funcall(sprite, rb_intern("layout_size"), 0);
1368
+ w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
1369
+ h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
1370
+ pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
1371
+ pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
1372
+ ow = NUM2INT(*(RSTRUCT_PTR(osize) + 0));
1373
+ oh = NUM2INT(*(RSTRUCT_PTR(osize) + 1));
1341
1374
 
1342
- int x, y;
1343
1375
  for(y = 0; y < h; y++){
1344
1376
  for(x = 0; x < w; x++){
1345
1377
  if(pos_x > 0) pos_x -= ow;
1346
1378
  if(pos_y > 0) pos_y -= oh;
1347
- VALUE vx = INT2NUM(pos_x + x * ow);
1348
- VALUE vy = INT2NUM(pos_y + y * oh);
1379
+ vx = INT2NUM(pos_x + x * ow);
1380
+ vy = INT2NUM(pos_y + y * oh);
1349
1381
  rb_funcall(sprite, rb_intern("render_xy"), 2, vx, vy);
1350
1382
  }
1351
1383
  }
@@ -1354,31 +1386,32 @@ static VALUE plane_render(VALUE self)
1354
1386
  }
1355
1387
 
1356
1388
  /*
1357
- プレーンを画像に描画する
1358
1389
  */
1359
1390
  static VALUE plane_render_to_sprite(VALUE self, VALUE vdst)
1360
1391
  {
1392
+ VALUE sprite, pos, size, osize, vx, vy;
1393
+ int x, y, w, h, pos_x, pos_y, ow, oh;
1394
+
1361
1395
  VALUE visible = rb_iv_get(self, str_visible);
1362
1396
  if(visible == Qfalse) return self;
1363
- VALUE sprite = rb_iv_get(self, "@sprite");
1364
-
1365
- VALUE pos = rb_iv_get(self, "@pos");
1366
- VALUE size = rb_iv_get(self, "@size");
1367
- VALUE osize = rb_funcall(sprite, rb_intern("layout_size"), 0);
1368
- int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
1369
- int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
1370
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
1371
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
1372
- int ow = NUM2INT(*(RSTRUCT_PTR(osize) + 0));
1373
- int oh = NUM2INT(*(RSTRUCT_PTR(osize) + 1));
1397
+ sprite = rb_iv_get(self, "@sprite");
1398
+
1399
+ pos = rb_iv_get(self, "@pos");
1400
+ size = rb_iv_get(self, "@size");
1401
+ osize = rb_funcall(sprite, rb_intern("layout_size"), 0);
1402
+ w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
1403
+ h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
1404
+ pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
1405
+ pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
1406
+ ow = NUM2INT(*(RSTRUCT_PTR(osize) + 0));
1407
+ oh = NUM2INT(*(RSTRUCT_PTR(osize) + 1));
1374
1408
 
1375
- int x, y;
1376
1409
  for(y = 0; y < h; y++){
1377
1410
  for(x = 0; x < w; x++){
1378
1411
  if(pos_x > 0) pos_x -= ow;
1379
1412
  if(pos_y > 0) pos_y -= oh;
1380
- VALUE vx = INT2NUM(pos_x + x * ow);
1381
- VALUE vy = INT2NUM(pos_y + y * oh);
1413
+ vx = INT2NUM(pos_x + x * ow);
1414
+ vy = INT2NUM(pos_y + y * oh);
1382
1415
  rb_funcall(sprite, rb_intern("render_xy_to"), 3, vdst, vx, vy);
1383
1416
  }
1384
1417
  }
@@ -1391,12 +1424,14 @@ static VALUE plane_render_to_sprite(VALUE self, VALUE vdst)
1391
1424
  */
1392
1425
  static VALUE textbox_render(VALUE self)
1393
1426
  {
1427
+ VALUE wait_cursor, waiting, select_cursor;
1428
+
1394
1429
  if(rb_iv_get(self, str_visible) == Qfalse){ return self; }
1395
1430
  sprite_render(rb_iv_get(self, str_textarea));
1396
- VALUE wait_cursor = rb_iv_get(self, str_wait_cursor);
1431
+ wait_cursor = rb_iv_get(self, str_wait_cursor);
1397
1432
  if(wait_cursor != Qnil)
1398
1433
  {
1399
- VALUE waiting = rb_iv_get(self, str_waiting);
1434
+ waiting = rb_iv_get(self, str_waiting);
1400
1435
  if(waiting == Qtrue)
1401
1436
  {
1402
1437
  rb_funcall(wait_cursor, id_render, 0);
@@ -1406,7 +1441,7 @@ static VALUE textbox_render(VALUE self)
1406
1441
  if(rb_iv_get(self, str_selecting) == Qtrue)
1407
1442
  {
1408
1443
  rb_funcall(rb_iv_get(self, str_choices), id_render, 0);
1409
- VALUE select_cursor = rb_iv_get(self, str_select_cursor);
1444
+ select_cursor = rb_iv_get(self, str_select_cursor);
1410
1445
  if(select_cursor != Qnil)
1411
1446
  {
1412
1447
  rb_funcall(select_cursor, id_render, 0);
@@ -1420,13 +1455,14 @@ static VALUE textbox_render(VALUE self)
1420
1455
  */
1421
1456
  static VALUE textbox_render_to(VALUE self, VALUE dst)
1422
1457
  {
1458
+ VALUE wait_cursor, waiting, select_cursor;
1423
1459
 
1424
1460
  if(rb_iv_get(self, str_visible) == Qfalse){ return self; }
1425
1461
  sprite_render_to_sprite(rb_iv_get(self, str_textarea), dst);
1426
- VALUE wait_cursor = rb_iv_get(self, str_wait_cursor);
1462
+ wait_cursor = rb_iv_get(self, str_wait_cursor);
1427
1463
  if(wait_cursor != Qnil)
1428
1464
  {
1429
- VALUE waiting = rb_iv_get(self, str_waiting);
1465
+ waiting = rb_iv_get(self, str_waiting);
1430
1466
  if(waiting == Qtrue)
1431
1467
  {
1432
1468
  rb_funcall(wait_cursor, id_render_to, 1, dst);
@@ -1436,7 +1472,7 @@ static VALUE textbox_render_to(VALUE self, VALUE dst)
1436
1472
  if(rb_iv_get(self, str_selecting) == Qtrue)
1437
1473
  {
1438
1474
  rb_funcall(rb_iv_get(self, str_choices), id_render_to, 1, dst);
1439
- VALUE select_cursor = rb_iv_get(self, str_select_cursor);
1475
+ select_cursor = rb_iv_get(self, str_select_cursor);
1440
1476
  if(select_cursor != Qnil)
1441
1477
  {
1442
1478
  rb_funcall(select_cursor, id_render_to, 1, dst);