ruby-miyako 2.1.0 → 2.1.1
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 +275 -20
- data/extern.h +21 -1
- data/install_miyako.rb +5 -3
- data/lib/Miyako/API/audio.rb +11 -6
- data/lib/Miyako/API/basic_data.rb +0 -985
- data/lib/Miyako/API/bitmap.rb +19 -22
- data/lib/Miyako/API/choices.rb +203 -69
- data/lib/Miyako/API/collision.rb +451 -9
- data/lib/Miyako/API/color.rb +177 -0
- data/lib/Miyako/API/diagram.rb +18 -20
- data/lib/Miyako/API/fixedmap.rb +207 -73
- data/lib/Miyako/API/font.rb +111 -18
- data/lib/Miyako/API/i_yuki.rb +1201 -0
- data/lib/Miyako/API/input.rb +65 -0
- data/lib/Miyako/API/layout.rb +41 -29
- data/lib/Miyako/API/map.rb +202 -157
- data/lib/Miyako/API/map_event.rb +86 -19
- data/lib/Miyako/API/map_struct.rb +268 -0
- data/lib/Miyako/API/modules.rb +136 -37
- data/lib/Miyako/API/movie.rb +8 -8
- data/lib/Miyako/API/parts.rb +63 -20
- data/lib/Miyako/API/plane.rb +4 -4
- data/lib/Miyako/API/screen.rb +16 -8
- data/lib/Miyako/API/sprite.rb +290 -23
- data/lib/Miyako/API/sprite_animation.rb +23 -11
- data/lib/Miyako/API/sprite_list.rb +406 -183
- data/lib/Miyako/API/story.rb +4 -65
- data/lib/Miyako/API/struct_point.rb +157 -0
- data/lib/Miyako/API/struct_rect.rb +233 -0
- data/lib/Miyako/API/struct_segment.rb +641 -0
- data/lib/Miyako/API/struct_size.rb +158 -0
- data/lib/Miyako/API/struct_square.rb +253 -0
- data/lib/Miyako/API/textbox.rb +49 -35
- data/lib/Miyako/API/viewport.rb +5 -5
- data/lib/Miyako/API/wait_counter.rb +350 -0
- data/lib/Miyako/API/yuki.rb +95 -60
- data/lib/Miyako/EXT/raster_scroll.rb +30 -8
- data/lib/Miyako/EXT/slides.rb +6 -6
- data/lib/Miyako/miyako.rb +25 -11
- data/lib/miyako.rb +28 -0
- data/lib/miyako_require_only.rb +35 -0
- data/miyako_basicdata.c +201 -17
- data/miyako_collision.c +315 -6
- data/miyako_diagram.c +331 -0
- data/miyako_drawing.c +26 -7
- data/miyako_font.c +259 -129
- data/miyako_input_audio.c +24 -14
- data/miyako_layout.c +106 -8
- data/miyako_no_katana.c +398 -171
- data/miyako_sprite2.c +275 -38
- data/miyako_transform.c +113 -107
- data/miyako_utility.c +34 -48
- data/miyako_yuki.c +241 -0
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +30 -30
- data/sample/Room3/blue.rb +19 -19
- data/sample/Room3/green.rb +9 -9
- data/sample/Room3/main.rb +12 -12
- data/sample/Room3/red.rb +12 -12
- data/sample/Room3/title.rb +15 -10
- data/sample/collision_test2.rb +2 -1
- data/sample/fixed_map_test/fixed_map_sample.rb +7 -6
- data/sample/map_test/main_scene.rb +12 -10
- data/sample/map_test/map_manager.rb +14 -13
- data/sample/rasterscroll.rb +5 -5
- data/sample/takahashi.rb +3 -3
- data/sample/textbox_sample.rb +7 -6
- data/sample/transform.rb +2 -1
- data/uninstall_miyako.rb +4 -1
- data/win/miyako_no_katana.so +0 -0
- metadata +15 -4
- data/lib/Miyako/EXT/miyako_cairo.rb +0 -62
- data/sample/cairo_sample.rb +0 -25
    
        data/miyako_font.c
    CHANGED
    
    | @@ -63,7 +63,7 @@ static VALUE font_draw_text(VALUE self, VALUE vdst, VALUE str, VALUE vx, VALUE v | |
| 63 63 | 
             
              StringValue(str);
         | 
| 64 64 |  | 
| 65 65 | 
             
              str = rb_funcall(str, id_encode, 1, rb_const_get(cEncoding, id_utf8));
         | 
| 66 | 
            -
             | 
| 66 | 
            +
             | 
| 67 67 | 
             
              TTF_Font *font = Get_TTFont(rb_iv_get(self, "@font"))->font;
         | 
| 68 68 |  | 
| 69 69 | 
             
              VALUE *p_font_color = RARRAY_PTR(rb_iv_get(self, "@color"));
         | 
| @@ -88,8 +88,9 @@ static VALUE font_draw_text(VALUE self, VALUE vdst, VALUE str, VALUE vx, VALUE v | |
| 88 88 | 
             
              int hspace = NUM2INT(rb_iv_get(self, "@hspace"));
         | 
| 89 89 |  | 
| 90 90 | 
             
              SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
         | 
| 91 | 
            +
              SDL_Rect drect;
         | 
| 91 92 |  | 
| 92 | 
            -
             | 
| 93 | 
            +
              MiyakoBitmap src, dst;
         | 
| 93 94 | 
             
              _miyako_setup_unit(vdst, scr, &dst, vx, vy, 0);
         | 
| 94 95 |  | 
| 95 96 | 
             
              char *sptr = RSTRING_PTR(str);
         | 
| @@ -97,7 +98,9 @@ static VALUE font_draw_text(VALUE self, VALUE vdst, VALUE str, VALUE vx, VALUE v | |
| 97 98 | 
             
              src.x = dst.x;
         | 
| 98 99 | 
             
              src.y = dst.y;
         | 
| 99 100 |  | 
| 100 | 
            -
             | 
| 101 | 
            +
              int x, y;
         | 
| 102 | 
            +
              Uint32 sr, sg, sb, sa;
         | 
| 103 | 
            +
              Uint32 dr, dg, db, da;
         | 
| 101 104 |  | 
| 102 105 | 
             
              if(use_shadow == Qtrue)
         | 
| 103 106 | 
             
              {
         | 
| @@ -105,77 +108,140 @@ static VALUE font_draw_text(VALUE self, VALUE vdst, VALUE str, VALUE vx, VALUE v | |
| 105 108 |  | 
| 106 109 | 
             
                if(ssrc2 == NULL) return INT2NUM(src.x);
         | 
| 107 110 | 
             
                Uint32 *psrc2 = (Uint32 *)(ssrc2->pixels);
         | 
| 108 | 
            -
             | 
| 111 | 
            +
             | 
| 109 112 | 
             
                src.x += shadow_margin_x;
         | 
| 110 113 | 
             
                src.y += shadow_margin_y;
         | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
            		size2.w = dst.rect.w - (src.x < 0 ? -(src.x) : src.x);
         | 
| 114 | 
            -
            		size2.h = dst.rect.h - (src.y < 0 ? -(src.y) : src.y);
         | 
| 115 | 
            -
            		if(size2.w > ssrc2->w){ size2.w = ssrc2->w; }
         | 
| 116 | 
            -
            		if(size2.h > ssrc2->h){ size2.h = ssrc2->h; }
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                SDL_LockSurface(ssrc2);
         | 
| 119 | 
            -
                SDL_LockSurface(dst.surface);
         | 
| 120 | 
            -
              
         | 
| 121 | 
            -
                for(y = 0; y < size2.h; y++)
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                if(dst.surface == scr)
         | 
| 122 116 | 
             
                {
         | 
| 123 | 
            -
                   | 
| 124 | 
            -
                   | 
| 125 | 
            -
                   | 
| 117 | 
            +
                  drect.x = src.x;
         | 
| 118 | 
            +
                  drect.y = src.y;
         | 
| 119 | 
            +
                  SDL_BlitSurface(ssrc2, NULL, dst.surface, &(drect));
         | 
| 120 | 
            +
                }
         | 
| 121 | 
            +
                else
         | 
| 122 | 
            +
                {
         | 
| 123 | 
            +
                  MiyakoSize size2;
         | 
| 124 | 
            +
                  size2.w = dst.rect.w - (src.x < 0 ? 0 : src.x);
         | 
| 125 | 
            +
                  if(size2.w <= 0)
         | 
| 126 126 | 
             
                  {
         | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 127 | 
            +
                    SDL_FreeSurface(ssrc2);
         | 
| 128 | 
            +
                    return INT2NUM(dst.x);
         | 
| 129 | 
            +
                  }
         | 
| 130 | 
            +
                  if(size2.w > ssrc2->w){ size2.w = ssrc2->w; }
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  int margin_x = 0;
         | 
| 133 | 
            +
                  if(src.x < 0)
         | 
| 134 | 
            +
                  {
         | 
| 135 | 
            +
                    int tmp_w = ssrc2->w + src.x;
         | 
| 136 | 
            +
                    if(tmp_w < size2.w) size2.w += src.x;
         | 
| 137 | 
            +
                    if(size2.w <= 0)
         | 
| 138 | 
            +
                    {
         | 
| 139 | 
            +
                      SDL_FreeSurface(ssrc2);
         | 
| 140 | 
            +
                      return INT2NUM(dst.x);
         | 
| 136 141 | 
             
                    }
         | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
                     | 
| 145 | 
            -
                     | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
                     | 
| 153 | 
            -
                    if( | 
| 154 | 
            -
             | 
| 142 | 
            +
                    margin_x = -src.x;
         | 
| 143 | 
            +
                    src.x = 0;
         | 
| 144 | 
            +
                  }
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                  size2.h = dst.rect.h - (src.y < 0 ? 0 : src.y);
         | 
| 147 | 
            +
                  if(size2.h <= 0)
         | 
| 148 | 
            +
                  {
         | 
| 149 | 
            +
                    SDL_FreeSurface(ssrc2);
         | 
| 150 | 
            +
                    return INT2NUM(dst.x);
         | 
| 151 | 
            +
                  }
         | 
| 152 | 
            +
                  if(size2.h > ssrc2->h){ size2.h = ssrc2->h; }
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                  int margin_y = 0;
         | 
| 155 | 
            +
                  if(src.y < 0)
         | 
| 156 | 
            +
                  {
         | 
| 157 | 
            +
                    int tmp_h = ssrc2->h + src.y;
         | 
| 158 | 
            +
                    if(tmp_h < size2.h) size2.h += src.y;
         | 
| 159 | 
            +
                    if(size2.h <= 0)
         | 
| 160 | 
            +
                    {
         | 
| 161 | 
            +
                      SDL_FreeSurface(ssrc2);
         | 
| 162 | 
            +
                      return INT2NUM(dst.x);
         | 
| 163 | 
            +
                    }
         | 
| 164 | 
            +
                    margin_y = -src.y;
         | 
| 165 | 
            +
                    src.y = 0;
         | 
| 166 | 
            +
                  }
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                  SDL_LockSurface(ssrc2);
         | 
| 169 | 
            +
                  SDL_LockSurface(dst.surface);
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                  for(y = 0; y < size2.h; y++)
         | 
| 172 | 
            +
                  {
         | 
| 173 | 
            +
                    Uint32 *ppsrc2 = psrc2 + (y+margin_y) * ssrc2->w + margin_x;
         | 
| 174 | 
            +
                    Uint32 *ppdst = dst.ptr + (src.y + y) * dst.surface->w + src.x;
         | 
| 175 | 
            +
                    for(x = 0; x < size2.w; x++)
         | 
| 176 | 
            +
                    {
         | 
| 177 | 
            +
              #if SDL_BYTEORDER == SDL_LIL_ENDIAN
         | 
| 178 | 
            +
                      da = (*ppdst >> 24) | dst.a255;
         | 
| 179 | 
            +
                      sa = *ppsrc2 >> 24;
         | 
| 180 | 
            +
                      if(sa == 0){ ppsrc2++; ppdst++; continue; }
         | 
| 181 | 
            +
                      if(da == 0 || sa == 255){
         | 
| 182 | 
            +
                        *ppdst = *ppsrc2;
         | 
| 183 | 
            +
                        ppsrc2++;
         | 
| 184 | 
            +
                        ppdst++;
         | 
| 185 | 
            +
                        continue;
         | 
| 186 | 
            +
                      }
         | 
| 187 | 
            +
              #if 0
         | 
| 188 | 
            +
                      dr = (Uint32)((*ppdst >> 16)) & 0xff;
         | 
| 189 | 
            +
                      dg = (Uint32)((*ppdst >> 8)) & 0xff;
         | 
| 190 | 
            +
                      db = (Uint32)((*ppdst)) & 0xff;
         | 
| 191 | 
            +
                      sr = (Uint32)((*ppsrc2 >> 16)) & 0xff;
         | 
| 192 | 
            +
                      sg = (Uint32)((*ppsrc2 >> 8)) & 0xff;
         | 
| 193 | 
            +
                      sb = (Uint32)((*ppsrc2)) & 0xff;
         | 
| 194 | 
            +
                      int a1 = sa + 1;
         | 
| 195 | 
            +
                      int a2 = 256 - sa;
         | 
| 196 | 
            +
                      *ppdst = (((sr * a1 + dr * a2) >> 8)) << 16 |
         | 
| 197 | 
            +
                               (((sg * a1 + dg * a2) >> 8)) << 8 |
         | 
| 198 | 
            +
                               (((sb * a1 + db * a2) >> 8)) |
         | 
| 199 | 
            +
                               0xff000000;
         | 
| 200 | 
            +
              #else
         | 
| 201 | 
            +
                      dr = *ppdst & 0xff0000;
         | 
| 202 | 
            +
                      dg = *ppdst & 0xff00;
         | 
| 203 | 
            +
                      db = *ppdst & 0xff;
         | 
| 204 | 
            +
                      sr = *ppsrc2 & 0xff0000;
         | 
| 205 | 
            +
                      sg = *ppsrc2 & 0xff00;
         | 
| 206 | 
            +
                      sb = *ppsrc2 & 0xff;
         | 
| 207 | 
            +
                      int a1 = sa + 1;
         | 
| 208 | 
            +
                      int a2 = 256 - sa;
         | 
| 209 | 
            +
                      *ppdst = ((sr * a1 + dr * a2) & 0xff000000 |
         | 
| 210 | 
            +
                                (sg * a1 + dg * a2) & 0xff0000   |
         | 
| 211 | 
            +
                                (sb * a1 + db * a2)) >> 8        |
         | 
| 212 | 
            +
                               0xff000000;
         | 
| 213 | 
            +
              #endif
         | 
| 214 | 
            +
              #else
         | 
| 215 | 
            +
                      da = (Uint32)(((*ppdst & dst.fmt->Amask) | dst.a255;
         | 
| 216 | 
            +
                      sa = (Uint32)(((*ppsrc2 & ssrc2->format->Amask)));
         | 
| 217 | 
            +
                      if(sa == 0){ ppsrc2++; ppdst++; continue; }
         | 
| 218 | 
            +
                      if(da == 0 || sa == 255){
         | 
| 219 | 
            +
                        *ppdst = *ppsrc2;
         | 
| 220 | 
            +
                        ppsrc2++;
         | 
| 221 | 
            +
                        ppdst++;
         | 
| 222 | 
            +
                        continue;
         | 
| 223 | 
            +
                      }
         | 
| 224 | 
            +
                      dr = (Uint32)(((*ppdst & dst.fmt->Rmask) >> dst.fmt->Rshift));
         | 
| 225 | 
            +
                      dg = (Uint32)(((*ppdst & dst.fmt->Gmask) >> dst.fmt->Gshift));
         | 
| 226 | 
            +
                      db = (Uint32)(((*ppdst & dst.fmt->Bmask) >> dst.fmt->Bshift));
         | 
| 227 | 
            +
                      sr = (Uint32)(((*ppsrc2 & ssrc2->format->Rmask) >> ssrc2->format->Rshift));
         | 
| 228 | 
            +
                      sg = (Uint32)(((*ppsrc2 & ssrc2->format->Gmask) >> ssrc2->format->Gshift));
         | 
| 229 | 
            +
                      sb = (Uint32)(((*ppsrc2 & ssrc2->format->Bmask) >> ssrc2->format->Bshift));
         | 
| 230 | 
            +
                      int a1 = sa + 1;
         | 
| 231 | 
            +
                      int a2 = 256 - sa;
         | 
| 232 | 
            +
                      *ppdst = (((sr * a1 + dr * a2) >> 8)) << dst.fmt->Rshift |
         | 
| 233 | 
            +
                               (((sg * a1 + dg * a2) >> 8)) << dst.fmt->Gshift |
         | 
| 234 | 
            +
                               (((sb * a1 + db * a2) >> 8)) << dst.fmt->Bshift |
         | 
| 235 | 
            +
                               (255 >> dst.fmt->Aloss);
         | 
| 236 | 
            +
              #endif
         | 
| 155 237 | 
             
                      ppsrc2++;
         | 
| 156 238 | 
             
                      ppdst++;
         | 
| 157 | 
            -
                      continue;
         | 
| 158 239 | 
             
                    }
         | 
| 159 | 
            -
            				dst.color.r = (Uint32)(((*ppdst & dst.fmt->Rmask) >> dst.fmt->Rshift));
         | 
| 160 | 
            -
            				dst.color.g = (Uint32)(((*ppdst & dst.fmt->Gmask) >> dst.fmt->Gshift));
         | 
| 161 | 
            -
            				dst.color.b = (Uint32)(((*ppdst & dst.fmt->Bmask) >> dst.fmt->Bshift));
         | 
| 162 | 
            -
            	      src.color.r = (Uint32)(((*ppsrc2 & ssrc2->format->Rmask) >> ssrc2->format->Rshift));
         | 
| 163 | 
            -
            	      src.color.g = (Uint32)(((*ppsrc2 & ssrc2->format->Gmask) >> ssrc2->format->Gshift));
         | 
| 164 | 
            -
            	      src.color.b = (Uint32)(((*ppsrc2 & ssrc2->format->Bmask) >> ssrc2->format->Bshift));
         | 
| 165 | 
            -
                    int a1 = src.color.a + 1;
         | 
| 166 | 
            -
                    int a2 = 256 - src.color.a;
         | 
| 167 | 
            -
                    *ppdst = (((src.color.r * a1 + dst.color.r * a2) >> 8)) << dst.fmt->Rshift |
         | 
| 168 | 
            -
                             (((src.color.g * a1 + dst.color.g * a2) >> 8)) << dst.fmt->Gshift |
         | 
| 169 | 
            -
                             (((src.color.b * a1 + dst.color.b * a2) >> 8)) << dst.fmt->Bshift |
         | 
| 170 | 
            -
                             (255 >> dst.fmt->Aloss);
         | 
| 171 | 
            -
            #endif
         | 
| 172 | 
            -
                    ppsrc2++;
         | 
| 173 | 
            -
                    ppdst++;
         | 
| 174 240 | 
             
                  }
         | 
| 175 | 
            -
                }
         | 
| 176 241 |  | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 242 | 
            +
                  SDL_UnlockSurface(ssrc2);
         | 
| 243 | 
            +
                  SDL_UnlockSurface(dst.surface);
         | 
| 244 | 
            +
                }
         | 
| 179 245 |  | 
| 180 246 | 
             
                SDL_FreeSurface(ssrc2);
         | 
| 181 247 |  | 
| @@ -187,75 +253,139 @@ static VALUE font_draw_text(VALUE self, VALUE vdst, VALUE str, VALUE vx, VALUE v | |
| 187 253 |  | 
| 188 254 | 
             
              if(ssrc == NULL) return INT2NUM(src.x);
         | 
| 189 255 |  | 
| 190 | 
            -
               | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
             | 
| 256 | 
            +
              if(dst.surface == scr)
         | 
| 257 | 
            +
              {
         | 
| 258 | 
            +
                drect.x = src.x;
         | 
| 259 | 
            +
                drect.y = src.y;
         | 
| 260 | 
            +
                SDL_BlitSurface(ssrc, NULL, dst.surface, &(drect));
         | 
| 261 | 
            +
              }
         | 
| 262 | 
            +
              else
         | 
| 263 | 
            +
              {
         | 
| 264 | 
            +
                Uint32 *psrc = (Uint32 *)(ssrc->pixels);
         | 
| 265 | 
            +
             | 
| 266 | 
            +
                MiyakoSize size;
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                size.w = dst.rect.w - (src.x < 0 ? 0 : src.x);
         | 
| 269 | 
            +
                if(size.w <= 0)
         | 
| 270 | 
            +
                {
         | 
| 271 | 
            +
                  SDL_FreeSurface(ssrc);
         | 
| 272 | 
            +
                  return INT2NUM(dst.x);
         | 
| 273 | 
            +
                }
         | 
| 274 | 
            +
                if(size.w > ssrc->w){ size.w = ssrc->w; }
         | 
| 275 | 
            +
             | 
| 276 | 
            +
                int margin_x = 0;
         | 
| 277 | 
            +
                if(src.x < 0)
         | 
| 278 | 
            +
                {
         | 
| 279 | 
            +
                  int tmp_w = ssrc->w + src.x;
         | 
| 280 | 
            +
                  if(tmp_w < size.w) size.w += src.x;
         | 
| 281 | 
            +
                  if(size.w <= 0)
         | 
| 282 | 
            +
                  {
         | 
| 283 | 
            +
                    SDL_FreeSurface(ssrc);
         | 
| 284 | 
            +
                    return INT2NUM(dst.x);
         | 
| 285 | 
            +
                  }
         | 
| 286 | 
            +
                  margin_x = -src.x;
         | 
| 287 | 
            +
                  src.x = 0;
         | 
| 288 | 
            +
                }
         | 
| 289 | 
            +
             | 
| 290 | 
            +
                size.h = dst.rect.h - (src.y < 0 ? 0 : src.y);
         | 
| 291 | 
            +
                if(size.h <= 0)
         | 
| 292 | 
            +
                {
         | 
| 293 | 
            +
                  SDL_FreeSurface(ssrc);
         | 
| 294 | 
            +
                  return INT2NUM(dst.x);
         | 
| 295 | 
            +
                }
         | 
| 296 | 
            +
                if(size.h > ssrc->h){ size.h = ssrc->h; }
         | 
| 297 | 
            +
             | 
| 298 | 
            +
                int margin_y = 0;
         | 
| 299 | 
            +
                if(src.y < 0)
         | 
| 300 | 
            +
                {
         | 
| 301 | 
            +
                  int tmp_h = ssrc->h + src.y;
         | 
| 302 | 
            +
                  if(tmp_h < size.h) size.h += src.y;
         | 
| 303 | 
            +
                  if(size.h <= 0)
         | 
| 304 | 
            +
                  {
         | 
| 305 | 
            +
                    SDL_FreeSurface(ssrc);
         | 
| 306 | 
            +
                    return INT2NUM(dst.x);
         | 
| 307 | 
            +
                  }
         | 
| 308 | 
            +
                  margin_y = -src.y;
         | 
| 309 | 
            +
                  src.y = 0;
         | 
| 310 | 
            +
                }
         | 
| 311 | 
            +
             | 
| 312 | 
            +
                SDL_LockSurface(ssrc);
         | 
| 313 | 
            +
                SDL_LockSurface(dst.surface);
         | 
| 314 | 
            +
             | 
| 315 | 
            +
                for(y = 0; y < size.h; y++)
         | 
| 316 | 
            +
                {
         | 
| 317 | 
            +
                  Uint32 *ppsrc = psrc + (y+margin_y) * ssrc->w + margin_x;
         | 
| 318 | 
            +
                  Uint32 *ppdst = dst.ptr + (src.y + y) * dst.surface->w + src.x;
         | 
| 319 | 
            +
                  for(x = 0; x < size.w; x++)
         | 
| 320 | 
            +
                  {
         | 
| 207 321 | 
             
            #if SDL_BYTEORDER == SDL_LIL_ENDIAN
         | 
| 208 | 
            -
             | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
             | 
| 213 | 
            -
             | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 322 | 
            +
                    da = (*ppdst >> 24) | dst.a255;
         | 
| 323 | 
            +
                    sa = *ppsrc >> 24;
         | 
| 324 | 
            +
                    if(sa == 0){ ppsrc++; ppdst++; continue; }
         | 
| 325 | 
            +
                    if(da == 0 || sa == 255){
         | 
| 326 | 
            +
                      *ppdst = *ppsrc;
         | 
| 327 | 
            +
                      ppsrc++;
         | 
| 328 | 
            +
                      ppdst++;
         | 
| 329 | 
            +
                      continue;
         | 
| 330 | 
            +
                    }
         | 
| 331 | 
            +
            #if 0
         | 
| 332 | 
            +
                    dr = (Uint32)(((*ppdst) >> 16)) & 0xff;
         | 
| 333 | 
            +
                    dg = (Uint32)(((*ppdst) >> 8)) & 0xff;
         | 
| 334 | 
            +
                    db = (Uint32)(((*ppdst))) & 0xff;
         | 
| 335 | 
            +
                    sr = (Uint32)(((*ppsrc) >> 16)) & 0xff;
         | 
| 336 | 
            +
                    sg = (Uint32)(((*ppsrc) >> 8)) & 0xff;
         | 
| 337 | 
            +
                    sb = (Uint32)(((*ppsrc))) & 0xff;
         | 
| 338 | 
            +
                    int a1 = sa + 1;
         | 
| 339 | 
            +
                    int a2 = 256 - sa;
         | 
| 340 | 
            +
                    *ppdst = (((sr * a1 + dr * a2) >> 8)) << 16 |
         | 
| 341 | 
            +
                             (((sg * a1 + dg * a2) >> 8)) << 8 |
         | 
| 342 | 
            +
                             (((sb * a1 + db * a2) >> 8)) |
         | 
| 343 | 
            +
                             0xff000000;
         | 
| 344 | 
            +
            #else
         | 
| 345 | 
            +
                    dr = *ppdst & 0xff0000;
         | 
| 346 | 
            +
                    dg = *ppdst & 0xff00;
         | 
| 347 | 
            +
                    db = *ppdst & 0xff;
         | 
| 348 | 
            +
                    sr = *ppsrc & 0xff0000;
         | 
| 349 | 
            +
                    sg = *ppsrc & 0xff00;
         | 
| 350 | 
            +
                    sb = *ppsrc & 0xff;
         | 
| 351 | 
            +
                    int a1 = sa + 1;
         | 
| 352 | 
            +
                    int a2 = 256 - sa;
         | 
| 353 | 
            +
                    *ppdst = ((sr * a1 + dr * a2) & 0xff000000 |
         | 
| 354 | 
            +
                              (sg * a1 + dg * a2) & 0xff0000   |
         | 
| 355 | 
            +
                              (sb * a1 + db * a2)) >> 8        |
         | 
| 356 | 
            +
                             0xff000000;
         | 
| 357 | 
            +
            #endif
         | 
| 229 358 | 
             
            #else
         | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
             | 
| 238 | 
            -
             | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 248 | 
            -
             | 
| 249 | 
            -
             | 
| 250 | 
            -
             | 
| 359 | 
            +
                    da = (Uint32)(((*ppdst & dst.fmt->Amask)) << dst.fmt->Aloss) | dst.a255;
         | 
| 360 | 
            +
                    sa = (Uint32)(((*ppsrc & ssrc->format->Amask)) << ssrc->format->Aloss);
         | 
| 361 | 
            +
                    if(sa == 0){ ppsrc++; ppdst++; continue; }
         | 
| 362 | 
            +
                    if(da == 0 || sa == 255){
         | 
| 363 | 
            +
                      *ppdst = *ppsrc;
         | 
| 364 | 
            +
                      ppsrc++;
         | 
| 365 | 
            +
                      ppdst++;
         | 
| 366 | 
            +
                      continue;
         | 
| 367 | 
            +
                    }
         | 
| 368 | 
            +
                    dr = (Uint32)(((*ppdst & dst.fmt->Rmask) >> dst.fmt->Rshift));
         | 
| 369 | 
            +
                    dg = (Uint32)(((*ppdst & dst.fmt->Gmask) >> dst.fmt->Gshift));
         | 
| 370 | 
            +
                    db = (Uint32)(((*ppdst & dst.fmt->Bmask) >> dst.fmt->Bshift));
         | 
| 371 | 
            +
                    sr = (Uint32)(((*ppsrc & ssrc->format->Rmask) >> ssrc->format->Rshift));
         | 
| 372 | 
            +
                    sg = (Uint32)(((*ppsrc & ssrc->format->Gmask) >> ssrc->format->Gshift));
         | 
| 373 | 
            +
                    sb = (Uint32)(((*ppsrc & ssrc->format->Bmask) >> ssrc->format->Bshift));
         | 
| 374 | 
            +
                    int a1 = sa + 1;
         | 
| 375 | 
            +
                    int a2 = 256 - sa;
         | 
| 376 | 
            +
                    *ppdst = (((sr * a1 + dr * a2) >> 8)) << dst.fmt->Rshift |
         | 
| 377 | 
            +
                             (((sg * a1 + dg * a2) >> 8)) << dst.fmt->Gshift |
         | 
| 378 | 
            +
                             (((sb * a1 + db * a2) >> 8)) << dst.fmt->Bshift |
         | 
| 379 | 
            +
                             (255 >> dst.fmt->Aloss);
         | 
| 251 380 | 
             
            #endif
         | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 381 | 
            +
                    ppsrc++;
         | 
| 382 | 
            +
                    ppdst++;
         | 
| 383 | 
            +
                  }
         | 
| 384 | 
            +
                }
         | 
| 256 385 |  | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 386 | 
            +
                SDL_UnlockSurface(ssrc);
         | 
| 387 | 
            +
                SDL_UnlockSurface(dst.surface);
         | 
| 388 | 
            +
              }
         | 
| 259 389 | 
             
              SDL_FreeSurface(ssrc);
         | 
| 260 390 |  | 
| 261 391 | 
             
              int i, n;
         | 
    
        data/miyako_input_audio.c
    CHANGED
    
    | @@ -72,19 +72,19 @@ static VALUE input_update(VALUE self) | |
| 72 72 | 
             
              int i;
         | 
| 73 73 | 
             
              VALUE *ptr;
         | 
| 74 74 |  | 
| 75 | 
            -
              VALUE btn = rb_iv_get(self, "@@btn"); | 
| 76 | 
            -
              VALUE mouse = rb_iv_get(self, "@@mouse"); | 
| 77 | 
            -
              VALUE process = rb_iv_get(self, "@@process"); | 
| 78 | 
            -
              VALUE toggle = rb_iv_get(self, "@@toggle_screen_mode"); | 
| 75 | 
            +
              VALUE btn = rb_iv_get(self, "@@btn");
         | 
| 76 | 
            +
              VALUE mouse = rb_iv_get(self, "@@mouse");
         | 
| 77 | 
            +
              VALUE process = rb_iv_get(self, "@@process");
         | 
| 78 | 
            +
              VALUE toggle = rb_iv_get(self, "@@toggle_screen_mode");
         | 
| 79 79 |  | 
| 80 80 | 
             
              VALUE trigger = rb_hash_lookup(btn, sy_trigger);
         | 
| 81 81 | 
             
              VALUE pushed  = rb_hash_lookup(btn, sy_pushed);
         | 
| 82 82 | 
             
              VALUE click   = rb_hash_lookup(mouse, sy_click);
         | 
| 83 83 | 
             
              VALUE drop    = rb_hash_lookup(mouse, sy_drop);
         | 
| 84 84 | 
             
              VALUE pos     = rb_hash_lookup(mouse, sy_pos);
         | 
| 85 | 
            -
             | 
| 85 | 
            +
             | 
| 86 86 | 
             
              rb_funcall(cJoystick, id_update_all, 0);
         | 
| 87 | 
            -
             | 
| 87 | 
            +
             | 
| 88 88 | 
             
              VALUE keys = rb_funcall(pushed, rb_intern("keys"), 0);
         | 
| 89 89 | 
             
              ptr = RARRAY_PTR(keys);
         | 
| 90 90 | 
             
              for(i=0; i<RARRAY_LEN(keys); i++)
         | 
| @@ -100,7 +100,7 @@ static VALUE input_update(VALUE self) | |
| 100 100 | 
             
              rb_hash_aset(drop, sy_left, Qfalse);
         | 
| 101 101 | 
             
              rb_hash_aset(drop, sy_middle, Qfalse);
         | 
| 102 102 | 
             
              rb_hash_aset(drop, sy_right, Qfalse);
         | 
| 103 | 
            -
             | 
| 103 | 
            +
             | 
| 104 104 | 
             
              VALUE e_list = rb_ary_new();
         | 
| 105 105 | 
             
              VALUE e = rb_funcall(cEvent, id_poll, 0);
         | 
| 106 106 | 
             
              while(e != Qnil)
         | 
| @@ -125,10 +125,15 @@ static VALUE input_update(VALUE self) | |
| 125 125 | 
             
                  rb_hash_aset(pushed, sy_ent, nZero);
         | 
| 126 126 | 
             
                }
         | 
| 127 127 | 
             
              }
         | 
| 128 | 
            -
             | 
| 128 | 
            +
             | 
| 129 129 | 
             
              return Qnil;
         | 
| 130 130 | 
             
            }
         | 
| 131 131 |  | 
| 132 | 
            +
            void _miyako_input_update()
         | 
| 133 | 
            +
            {
         | 
| 134 | 
            +
              input_update(mInput);
         | 
| 135 | 
            +
            }
         | 
| 136 | 
            +
             | 
| 132 137 | 
             
            /*
         | 
| 133 138 | 
             
            :nodoc:
         | 
| 134 139 | 
             
            */
         | 
| @@ -136,7 +141,7 @@ static VALUE bgm_update(VALUE self) | |
| 136 141 | 
             
            {
         | 
| 137 142 | 
             
              VALUE nua = rb_gv_get("$not_use_audio");
         | 
| 138 143 | 
             
              if(nua == Qfalse) return Qnil;
         | 
| 139 | 
            -
             | 
| 144 | 
            +
             | 
| 140 145 | 
             
              VALUE pb = rb_iv_get(self, "@@playin_bgm");
         | 
| 141 146 | 
             
              if(pb == Qnil) return Qnil;
         | 
| 142 147 |  | 
| @@ -167,14 +172,14 @@ static VALUE se_update(VALUE self) | |
| 167 172 | 
             
            {
         | 
| 168 173 | 
             
              VALUE nua = rb_gv_get("$not_use_audio");
         | 
| 169 174 | 
             
              if(nua == Qfalse) return Qnil;
         | 
| 170 | 
            -
             | 
| 175 | 
            +
             | 
| 171 176 | 
             
              VALUE playings = rb_iv_get(self, "@@playings");
         | 
| 172 177 | 
             
              VALUE *ptr = RARRAY_PTR(playings);
         | 
| 173 178 | 
             
              int i;
         | 
| 174 179 | 
             
              for(i=0; i<RARRAY_LEN(playings); i++)
         | 
| 175 180 | 
             
              {
         | 
| 176 181 | 
             
                VALUE pl = *(ptr+i);
         | 
| 177 | 
            -
             | 
| 182 | 
            +
             | 
| 178 183 | 
             
              if(rb_funcall(pl, id_is_playing_wo_loop, 0) == Qfalse &&
         | 
| 179 184 | 
             
                   rb_funcall(pl, id_in_the_loop, 0) == Qtrue)
         | 
| 180 185 | 
             
                {
         | 
| @@ -192,7 +197,7 @@ static VALUE se_update(VALUE self) | |
| 192 197 | 
             
                  rb_funcall(pl, id_allow_countup, 0);
         | 
| 193 198 | 
             
                }
         | 
| 194 199 | 
             
              }
         | 
| 195 | 
            -
             | 
| 200 | 
            +
             | 
| 196 201 | 
             
              return Qnil;
         | 
| 197 202 | 
             
            }
         | 
| 198 203 |  | 
| @@ -206,6 +211,11 @@ static VALUE audio_update(VALUE self) | |
| 206 211 | 
             
              return self;
         | 
| 207 212 | 
             
            }
         | 
| 208 213 |  | 
| 214 | 
            +
            void _miyako_audio_update()
         | 
| 215 | 
            +
            {
         | 
| 216 | 
            +
              audio_update(mAudio);
         | 
| 217 | 
            +
            }
         | 
| 218 | 
            +
             | 
| 209 219 | 
             
            void Init_miyako_input_audio()
         | 
| 210 220 | 
             
            {
         | 
| 211 221 | 
             
              mSDL = rb_define_module("SDL");
         | 
| @@ -247,8 +257,8 @@ void Init_miyako_input_audio() | |
| 247 257 | 
             
              one = 1;
         | 
| 248 258 | 
             
              nOne = INT2NUM(one);
         | 
| 249 259 |  | 
| 250 | 
            -
               | 
| 251 | 
            -
               | 
| 260 | 
            +
              rb_define_singleton_method(mInput, "update", input_update, 0);
         | 
| 261 | 
            +
              rb_define_singleton_method(mAudio, "update", audio_update, 0);
         | 
| 252 262 | 
             
              rb_define_singleton_method(cBGM, "update", bgm_update, 0);
         | 
| 253 263 | 
             
              rb_define_singleton_method(cSE, "update", se_update, 0);
         | 
| 254 264 | 
             
            }
         |