Changeset 60:e16e13d8cd68

Show
Ignore:
Timestamp:
12/18/09 20:41:38 (2 years ago)
Author:
Thibaut GIRKA <thib@…>
Branch:
default
Message:
Replaced SATURATE -> ADD, implemented objComposite, corrected minor things
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • scn2k/scn2k_grp.cc

    r56 r60  
    169169        if (picture == NULL) return; 
    170170        if (attr & UPDATE_POS) { 
    171                 if ( (attr & SATURATE) || zoom != -1) { 
     171                if (zoom != -1) { 
    172172                        int w=0, h=0; 
    173173                        GetSrcGeom(w,h); 
     
    239239                        picture->SetSurfaceRect(Rect(0,0,width,height)); 
    240240                } 
    241                 if (attr & SATURATE) 
    242                         picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); 
     241                if (attr & BLIT_ADD) 
     242                        picture->SetSurfaceAttribute(PicBase::BLIT_ADD); 
    243243        } else if (gtype == MOJI) { // ¥Æ¥­¥¹¥ÈÉÁ²è 
    244244                if (print_moji.length() == 0) return; 
     
    397397        } 
    398398 
    399         picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); 
    400         attr = Attribute(attr | UPDATE_POS | SATURATE); 
     399        attr = Attribute(attr | UPDATE_POS); 
    401400 
    402401        const char* buf = data + 16; 
     
    632631        RegisterCommand(1, 33, 1201, "recFill", (CmdImpl) &Grp::impl_recFill); 
    633632        RegisterCommand(1, 33, 1100, "recCopy", (CmdImpl) &Grp::impl_recCopy); 
    634         RegisterCommand(1, 33, 1101, "recMaskCopy", NULL); //FIXME 
     633        RegisterCommand(1, 33, 1101, "recMaskCopy", NULL); //TODO: Same thing as recCopy, but using source's alpha 
    635634        RegisterCommand(1, 33, 1600, "recAdd", (CmdImpl) &Grp::impl_recAdd); 
    636635        RegisterCommand(1, 33, 406, "grpPan", (CmdImpl) &Grp::impl_grpPan); 
     
    735734        RegisterCommand(1, 81, 1020, "objColLevel", NULL); 
    736735        RegisterCommand(1, 82, 1020, "objBgColLevel", NULL); 
    737         RegisterCommand(1, 81, 1021, "objComposite", NULL);//(CmdImpl) &Grp::impl_objComposite); //FIXME: May be broken 
     736        RegisterCommand(1, 81, 1021, "objComposite", (CmdImpl) &Grp::impl_objComposite); //FIXME: May be broken 
    738737        RegisterCommand(1, 82, 1021, "objBgComposite", (CmdImpl) &Grp::impl_objComposite); 
    739738        RegisterCommand(1, 81, 1024, "objSetText", (CmdImpl) &Grp::impl_objSetText); 
     
    15541553 
    15551554        //TODO: ??? 
    1556         if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0) { // ??? : KANOGI : ²èÁü¥ª¥Ö¥ž¥§¥¯¥È€Îºïœü¡© 
     1555        if (cmd.cmd1 == 1 && cmd.cmd2 == 60 && cmd.cmd3 == 0) { // ??? : KANOGI : ²èÁü¥ª¥Ö¥ž¥§¥¯¥È€Îºïœü¡© 
    15571556                DeleteObjPic(cmd.args[0].value); // µì¥Õ¥¡¥€¥ëÌŸ€Îsurface€òºïœü 
    15581557                GrpObj& g = grpobj[cmd.args[0].value]; 
     
    15611560        } 
    15621561 
    1563         //TODO: ??? 
    1564         if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && cmd.cmd2 == 0x51) { 
    1565                 /*GrpObj& g = grpobj[cmd.args[0].value]; 
    1566                 int attr; 
    1567                 GrpObjMap::iterator it; 
    1568                 for (it = g.children_obj.begin(); it != g.children_obj.end(); it++) 
    1569                         attr |= it->second.attr; 
    1570                 if (attr & GrpObj::UPDATE_ALL) 
    1571                         SetObjChanged(cmd.args[0].value);*/ 
     1562        // Refresh changed objects... 
     1563        //FIXME: should may be go away? 
     1564        //Seems it'll work only for objects in the foreground 
     1565        if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && cmd.cmd2 == 81) { 
    15721566                GrpObj* g; 
    15731567                if (cmd.cmd1 == 2) 
  • scn2k/scn2k_grp.h

    r56 r60  
    8282        vector<Rect> src_pos; 
    8383        enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype; 
    84         enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4, 
     84        enum Attribute { NONE=0, WIPEON=1, BLIT_ADD=2, HIDDEN=4, 
    8585                UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512, 
    8686                UPDATE_ALL = (UPDATE_PICTURE | UPDATE_POS | UPDATE_ALPHA | UPDATE_SNUM | UPDATE_CLIP | UPDATE_VISIBLE), 
  • scn2k/scn2k_grpimpl.cc

    r56 r60  
    157157 
    158158void Grp::impl_recCopy(Cmd& cmd) { 
     159        //TODO: Handle forms 0 and 1 
    159160        int sx = cmd.args[0].value; 
    160161        int sy = cmd.args[1].value; 
     
    174175                cmd.cmd_type = CMD_SAVECMDGRP; 
    175176        } 
    176  
    177177        else if (cmd.cmd4 == 3) { // alpha ぀きcopy 
    178178                unsigned char alpha; 
     
    193193 
    194194void Grp::impl_recAdd(Cmd& cmd) { 
    195         if (cmd.cmd4 == 3) { // saturate mode で alpha 付き copy 
     195        if (cmd.cmd4 == 3) { // add mode で alpha 付き copy 
    196196                int sx = cmd.args[0].value; 
    197197                int sy = cmd.args[1].value; 
     
    207207                else if (cmd.args[8].value > 255) alpha = 255; 
    208208                else alpha = cmd.args[8].value; 
    209                 eprintf("copy surface w/ saturate %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); 
     209                eprintf("copy surface w/ add %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); 
    210210                if (src == dest) { 
    211211                        DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); 
     
    213213                } 
    214214                if (alpha != 0) { 
    215                         // saturate mode : screen (picture) を䞀時的に䜜成 
     215                        // add mode : screen (picture) を䞀時的に䜜成 
    216216                        PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); 
    217                         screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_SATURATE); 
     217                        screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_ADD); 
    218218                        screen_tmp->SetSurfaceRect(rect); 
    219219                        screen_tmp->Move(dx, dy); 
     
    351351 
    352352        if (cmd.cmd3 == 1000) { /* ファむル名蚭定 */ 
    353                 g->gtype = GrpObj::FILE; //FIXME: Strange thing in the main menu; that happens with objComposite 
     353                g->gtype = GrpObj::FILE; 
    354354                string name = cmd.Str(cmd.args[base_argc + 1]); 
    355355                if (name.find('?') != -1) {//TODO 
     
    519519        int base_arg = 0; 
    520520        GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); 
    521  
    522521        if (cmd.args[base_arg + 1].value == 1) { 
    523                 g->attr = GrpObj::Attribute(g->attr | GrpObj::SATURATE); 
     522                g->attr = GrpObj::Attribute(g->attr | GrpObj::BLIT_ADD); 
    524523                cmd.clear(); 
    525524        } else if (cmd.args[base_arg + 1].value == 0) { 
    526                 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::SATURATE)); 
     525                g->attr = GrpObj::Attribute(g->attr & (~GrpObj::BLIT_ADD)); 
    527526                cmd.clear(); 
    528527        } 
     
    768767        } 
    769768} 
     769 
  • window/picture.cc

    r53 r60  
    4242using namespace std; 
    4343 
    44 int print_blit = 0; 
    4544/* render.cc */ 
    4645void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect); 
    47 void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); 
     46void DSurfaceBlitAdd(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); 
    4847void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); 
    4948void DSurfaceFill(Surface* src, const Rect& rect, int r, int g, int b, int a=0xff); // ¥¯¥ê¥¢ 
     
    181180        Rect abs_r = QueryAbsPos(rpos); 
    182181        Rect ppos = parent_pos(rpos); 
    183 if(print_blit) fprintf(stderr,"back."); 
    184182        if (parent) parent->BlitBack(z_pos, ppos); 
    185 if(print_blit) fprintf(stderr,"self."); 
    186183        if (!is_hidden_now) Blit(rpos); 
    187 if(print_blit) fprintf(stderr,"front."); 
    188184        if (parent) parent->BlitFront(z_pos, ppos); 
    189 if(print_blit) fprintf(stderr,"end."); 
    190185} 
    191186 
     
    325320        surface_alpha = 0; 
    326321        surface_alpha_rect = Rect(0,0); 
    327         attribute &= ~(BLIT_SATURATE | BLIT_MULTIPLY); 
     322        attribute &= ~(BLIT_ADD | BLIT_MULTIPLY); 
    328323        if (surface_own) { 
    329324                int key = SDL_MapRGB( ((SDL_Surface*)surface_own)->format, r, g, b); 
     
    403398                root->DeleteSurface(surface_own); 
    404399        } 
    405         attribute &= ~(SURFACE_FREE | BLIT_SATURATE | BLIT_MULTIPLY | NO_PICTURE | SOLID); 
     400        attribute &= ~(SURFACE_FREE | BLIT_ADD | BLIT_MULTIPLY | NO_PICTURE | SOLID); 
    406401        attribute |= new_attr; 
    407402        surface_own = new_surface; 
     
    470465 
    471466void PicBase::SetSurfaceAttribute(int new_attribute) { 
    472         attribute &= ~(BLIT_SATURATE | BLIT_MULTIPLY); 
    473         attribute |= new_attribute & (BLIT_SATURATE | BLIT_MULTIPLY); 
    474         if (new_attribute & (BLIT_SATURATE | BLIT_MULTIPLY)) { 
     467        attribute &= ~(BLIT_ADD | BLIT_MULTIPLY); 
     468        attribute |= new_attribute & (BLIT_ADD | BLIT_MULTIPLY); 
     469        if (new_attribute & (BLIT_ADD | BLIT_MULTIPLY)) { 
    475470                rel_solid_area = Rect(0,0); 
    476471        } 
     
    540535                Rect apos = (*z)->QueryAbsPos(cpos); 
    541536                Rect draw_rpos = (*z)->parent_pos(cpos); 
    542 if(print_blit) fprintf(stderr,"cahce."); 
    543537                root->BlitSurface(surface_back, draw_rpos, root->surface, apos); 
    544538                goto self_redraw; 
     
    547541        if (parent) { 
    548542                Rect ppos = parent_pos(rpos); 
    549 if(print_blit) fprintf(stderr,"parent-back."); 
    550543                parent->BlitBack(z_pos, ppos); 
    551544        } 
    552545        if (is_hidden_now) return; 
    553546self_redraw: 
    554 if(print_blit) fprintf(stderr,"back-self."); 
    555547        BlitSelf(rpos); // »Ò€ÏÉÁ²è€»€º¡¢Œ«Ê¬€À€±ÉÁ²è 
    556548children_redraw: 
     
    565557 
    566558void PicContainer::BlitChildren(Rect rpos) { 
    567 if (print_blit) fprintf(stderr,"bc."); 
    568559        iterator end = children.end(); 
    569560        for (iterator it = children.begin(); it != end; it++) { 
    570 if ( (*it)->is_hidden_now) if(print_blit) fprintf(stderr,"bch %p;",*it); 
    571561                if ( (*it)->is_hidden_now) continue; 
    572562                if ( (*it)->rel_pos.is_crossed(rpos)) { 
     
    602592        Rect apos = QueryAbsPos(rpos); 
    603593        // ɬÍ׀˱þ€ž€ÆÊÝž¡¢ÉÁ²è 
    604 if(print_blit) fprintf(stderr,"self-back."); 
    605594        if (attribute & CACHE_BACK) root->BlitSurface(root->surface, apos, surface_back, rpos); 
    606595        if (! (attribute & NO_PICTURE)) { 
     
    611600                        rpos.intersect(clip); 
    612601                } 
    613 if(print_blit) fprintf(stderr,"self-blit."); 
    614602                root->BlitSurface(surface_own, rpos, surface_alpha, surface_alpha_rect, root->surface, apos, attribute); 
    615603        } else if (parent == NULL) { // ¿Æ€¬€€€Ê€€€Ê€éÇØ·ÊŸÃµî€ÎÀÕÇ€€ò€â€Ä 
     
    895883        vector<UpdateItem>::iterator end = update_rects.end(); 
    896884 
    897 if(print_blit){ 
    898         fprintf(stderr,"ExecUpdate Start: \n\t"); 
    899         for (it=update_rects.begin(); it != end; it++) { 
    900                 fprintf(stderr,"(%d,%d,%d,%d), ",it->apos.lx,it->apos.ty,it->apos.rx,it->apos.by); 
    901         } 
    902         fprintf(stderr,"\n"); 
    903 } 
    904  
    905885        for (it=update_rects.begin(); it != end; it++) { 
    906886                if (it->rpos.width() == 0) continue; 
     
    926906        } 
    927907 
    928 if(print_blit){ 
    929         fprintf(stderr,"->\t"); 
    930         for (it=update_rects.begin(); it != end; it++) { 
    931                 fprintf(stderr,"(%d,%d,%d,%d), ",it->apos.lx,it->apos.ty,it->apos.rx,it->apos.by); 
    932         } 
    933         fprintf(stderr,"\n"); 
    934 } 
    935  
    936908        int num = update_rects.size(); 
    937909        SDL_Rect* r = new SDL_Rect[num]; 
     
    943915                Rect& ur = item.apos; 
    944916                if (ur.width() == 0) continue; 
    945 if(print_blit)fprintf(stderr,"%p: %d,%d,%d,%d",item.pic, item.apos.lx, item.apos.ty, item.apos.rx, item.apos.by); 
    946917 
    947918                item.pic->ExecReBlit(item.rpos); 
    948 if(print_blit)fprintf(stderr,"\n"); 
     919 
    949920                ur.intersect(confine); 
    950921                r[n].x = ur.lx; 
     
    955926                n++; 
    956927        } 
    957 if(print_blit)fprintf(stderr,"\n"); 
     928 
    958929        SDL_UpdateRects(hw_surface, n, r); 
    959930        delete[] r; 
     
    1017988#define ALPHA_MAX 255 
    1018989#endif 
    1019 void PicRoot::BlitSurface(Surface* src, const Rect& src_r, const unsigned char* alpha, const Rect& alpha_r, Surface* dest, const Rect& dest_r, int attribute) const { 
    1020 if (print_blit) fprintf(stderr," s %p %d:%d:%d:%d;",src, dest_r.lx, dest_r.ty, dest_r.rx, dest_r.by); 
     990void PicRoot::BlitSurface(Surface* src, const Rect& src_r, const unsigned char* alpha, const Rect& alpha_r, 
     991                          Surface* dest, const Rect& dest_r, int attribute) const 
     992{ 
    1021993        SDL_Rect sr = SDLed(src_r); SDL_Rect dr = SDLed(dest_r); 
    1022994 
    1023         if (attribute & PicBase::BLIT_MULTIPLY) { 
    1024 if (print_blit) fprintf(stderr,"M"); 
     995        if (attribute & PicBase::BLIT_MULTIPLY) 
     996        { 
    1025997                DSurfaceBlitMultiply(src, src_r, dest, dest_r); 
    1026998                return; 
    1027         } else if (attribute & PicBase::BLIT_SATURATE && src->format->Amask == 0) { 
    1028 if (print_blit) fprintf(stderr,"S"); 
     999        } 
     1000        else if (attribute & PicBase::BLIT_ADD) 
     1001        { 
    10291002                unsigned char a = 255; 
    1030                 if (alpha && alpha_r.width() >= 1 && alpha_r.height() >= 1) a = *alpha; 
    1031                 DSurfaceBlitSaturate(src, src_r, dest, dest_r, a); 
     1003                if (alpha != NULL && alpha_r.width() >= 1 && alpha_r.height() >= 1) 
     1004                        a = *alpha; 
     1005                DSurfaceBlitAdd(src, src_r, dest, dest_r, a); 
    10321006                return; 
    10331007        } 
    10341008 
    1035 if (print_blit) fprintf(stderr,"N"); 
    1036         if (alpha == NULL || alpha_r.width() == 0) { // simple blit 
    1037 if (print_blit) fprintf(stderr,"X"); 
     1009        if (alpha == NULL || alpha_r.width() == 0) // simple blit 
     1010        { 
    10381011                SDL_BlitSurface(src, &sr, dest, &dr); 
    10391012                return; 
     
    10411014        if (alpha_r.width() == 1 && alpha_r.height() == 1) { 
    10421015                if (*alpha == 255) { 
    1043 if (print_blit) fprintf(stderr,"Y"); 
    10441016                        SDL_BlitSurface(src, &sr, dest, &dr); 
    10451017                        return; 
    10461018                } 
    10471019                if (src->format->Amask == 0) { // use per-surface alpha 
    1048 if (print_blit) fprintf(stderr,"Z"); 
    10491020                        SDL_SetAlpha(src, SDL_SRCALPHA, *alpha); 
    10501021                        SDL_BlitSurface(src, &sr, dest, &dr); 
     
    10541025        } 
    10551026        // generic alpha blit 
    1056 if (print_blit) fprintf(stderr,"W"); 
    10571027        DSurfaceBlitAlpha(src, src_r, dest, dest_r, alpha, alpha_r); 
    1058         return; 
    10591028} 
    10601029 
  • window/picture.h

    r52 r60  
    7272                bool is_cached; 
    7373        public: 
    74                 enum { /*MOBILE=1,*/ CACHE_BACK=2, /* CACHE_SELF=4,*/ NO_PICTURE=8, SOLID = 16, SURFACE_FREE = 32, FIT_SURFACE = 64, BLIT_SATURATE = 128, BLIT_MULTIPLY = 256, ALPHA_FREE=512}; 
     74                enum { /*MOBILE=1,*/ CACHE_BACK=2, /* CACHE_SELF=4,*/ NO_PICTURE=8, SOLID = 16, SURFACE_FREE = 32, FIT_SURFACE = 64, BLIT_ADD = 128, BLIT_MULTIPLY = 256, ALPHA_FREE=512}; 
    7575        private: 
    7676                int attribute; 
  • window/render.cc

    r56 r60  
    252252#define CMASK2 0x00ff00 
    253253 
    254 inline void blit_pixel(Uint32* dmem, Uint32* smem, const unsigned char* amem, bool use_srcalpha) { 
    255         Uint32 d = *dmem; 
    256         Uint32 s = *smem; 
    257         Uint32 as = s>>ASHIFT; 
     254inline void blit_pixel(Uint32* dest, Uint32* src, const unsigned char* alpha, bool use_srcalpha) { 
     255        Uint32 dest_value = *dest; 
     256        Uint32 src_value = *src; 
     257        Uint32 as = src_value >> ASHIFT; 
    258258        if (as == 255 || (!use_srcalpha) ) { 
    259                 as = *amem; 
     259                as = *alpha; 
    260260        } else { 
    261                 as += as>>7; /* 0-0xff -> 0-0x100 */ 
    262                 as *= *amem; 
     261                as += (as >> 7); /* 0-0xff -> 0-0x100 */ 
     262                as *= *alpha; 
    263263                as >>= 8; 
    264264        } 
    265         as += as>>7; 
    266         Uint32 s1 = s & CMASK1; 
    267         Uint32 d1 = d & CMASK1; 
    268         d1 = (d1 + (((s1-d1) * as) >> 8)) & CMASK1; 
    269         s &= CMASK2; 
    270         d &= CMASK2; 
    271         d = (d + (((s-d) * as) >> 8)) & CMASK2; 
    272         *dmem = d1 | d | 0xff000000; 
    273 } 
    274  
    275 static void blit_line(Uint32* dmem, Uint32* smem, const unsigned char* amem,int ax0, int ax1, int awidth, int aj0, int aj1, bool use_srcalpha) { 
     265        as += as >> 7; 
     266        // Isolate Red and Blue components 
     267        Uint32 src_c1 = src_value & CMASK1; 
     268        Uint32 dest_c1 = dest_value & CMASK1; 
     269        // Blend Red and Blue components 
     270        dest_c1 = (dest_c1 + (((src_c1-dest_c1) * as) >> 8)) & CMASK1; 
     271        // Isolate Green component 
     272        src_value &= CMASK2; 
     273        dest_value &= CMASK2; 
     274        // Blend Green component 
     275        dest_value = (dest_value + (((src_value-dest_value) * as) >> 8)) & CMASK2; 
     276        // Put it alltogether 
     277        *dest = dest_c1 | dest_value | 0xff000000; 
     278} 
     279 
     280static void blit_line(Uint32* dest, Uint32* src, const unsigned char* alpha,int ax0, int ax1, int awidth, int aj0, int aj1, bool use_srcalpha) { 
    276281        int j; 
    277282        int ax = ax0; 
    278         const unsigned char* a = amem + ax0; 
    279         Uint32* d = dmem; 
    280         Uint32* s = smem; 
     283        const unsigned char* a = alpha + ax0; 
    281284        if (awidth == 1) { //  €ï€ê€È€è€¯€¢€ë€Î€ÇºÇŬ²œ 
    282285                for (j=aj0; j < aj1; j++) { 
    283                         blit_pixel(d++, s++, amem, use_srcalpha); 
    284                 } 
    285         } else { 
     286                        blit_pixel(dest++, src++, alpha, use_srcalpha); 
     287                } 
     288        } 
     289        else 
     290        { 
    286291                for (j=aj0; j < aj1; j++) { 
    287292                        for (; ax<awidth; ax++) 
    288                                 blit_pixel(d++, s++, a++, use_srcalpha); 
     293                                blit_pixel(dest++, src++, a++, use_srcalpha); 
    289294                        ax = 0; 
    290                         a = amem; 
    291                 } 
    292                 for (; ax < ax1; ax++) blit_pixel(d++, s++, a++, use_srcalpha); 
    293         } 
    294 } 
    295  
    296 void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect) { 
     295                        a = alpha; 
     296                } 
     297                for (; ax < ax1; ax++) 
     298                        blit_pixel(dest++, src++, a++, use_srcalpha); 
     299        } 
     300} 
     301 
     302void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect) 
     303{ 
    297304        SDL_Surface* dst = (SDL_Surface*)dst_o; 
    298305        SDL_Surface* src = (SDL_Surface*)src_o; 
     
    347354} 
    348355 
    349 void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, unsigned char alpha) { 
     356void DSurfaceBlitAdd(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, unsigned char alpha) { 
    350357        SDL_Surface* dst = (SDL_Surface*)dst_o; 
    351358        SDL_Surface* src = (SDL_Surface*)src_o; 
     
    371378        int gshift = fmt.Gshift - fmt.Gloss; int gmask = fmt.Gmask; 
    372379        int bshift = fmt.Bshift - fmt.Bloss; int bmask = fmt.Bmask; 
     380        int ashift = src->format->Ashift - src->format->Aloss; int amask = src->format->Amask; 
    373381        int allmask = rmask | gmask | bmask; 
    374         int i; 
    375         for (i=0; i<height; i++) { 
     382        int i, j; 
     383        for (i=0; i < height; i++) { 
    376384                char* d = dmem; char* s = smem; 
    377                 int j; for (j=0; j<width; j++) { 
     385                for (j=0; j < width; j++) { 
    378386                        Uint32 sd = *(Uint32*)s; 
    379387                        Uint32 dd = *(Uint32*)d; 
     
    382390                                Uint32 sg = (sd&gmask)>>gshift; 
    383391                                Uint32 sb = (sd&bmask)>>bshift; 
    384                                 if (alpha != ALPHA_MAX) { 
    385                                         sr = (sr*alpha)>>8; 
    386                                         sg = (sg*alpha)>>8; 
    387                                         sb = (sb*alpha)>>8; 
     392                                Uint32 alpha2 = alpha; 
     393                                if (amask) 
     394                                { 
     395                                        alpha2 = ((sd&amask)>>ashift); 
     396                                        alpha2 += alpha2 >> 7; 
     397                                        alpha2 *= alpha; 
     398                                        alpha2 >>= 8; 
     399                                } 
     400                                 
     401                                if (alpha2 != ALPHA_MAX) { 
     402                                        sr = (sr*alpha2)>>8; 
     403                                        sg = (sg*alpha2)>>8; 
     404                                        sb = (sb*alpha2)>>8; 
    388405                                } 
    389406                                Uint32 dr = sr + ((dd&rmask)>>rshift); 
  • window/render.h

    r56 r60  
    3939void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); // ¥³¥Ô¡Œ 
    4040void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect); 
    41 void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); 
     41void DSurfaceBlitAdd(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha); 
    4242void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o); 
    4343