Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //add calls to
- /*
- void putcombotranslucent(BITMAP* dest,int x,int y,int cmbdat,int cset,int opacity)
- and
- void putcombo(BITMAP* dest,int x,int y,int cmbdat,int cset)
- to use in DrawCombo, FastCombo, DrawLayer, and DrawScreen
- */
- class TileHelper
- {
- public:
- static void OldPutTile(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, byte skiprows=0)
- {
- // Past the end of the tile page?
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
- OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
- break;
- case 0:
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
- break;
- }
- }
- static void OverTile(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, byte skiprows=0)
- {
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- OverTile(_Dest, tile, x, y, w-w2, h, color, flip);
- OverTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- overtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- overtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- overtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
- break;
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- overtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
- break;
- }
- }
- static void OverTileTranslucent(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, int opacity, byte skiprows=0)
- {
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
- OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
- break;
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
- break;
- }
- }
- static void PutTileTranslucent(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, int opacity, byte skiprows=0)
- {
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
- PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
- break;
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
- break;
- }
- }
- static void OldPutCombo(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, byte skiprows=0)
- {
- // Past the end of the tile page?
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- oldputblock8(_Dest, tile, x, y, w-w2, h, color, flip,15);
- oldputblock8(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip,15);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- oldputblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip,15);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- oldputblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip,15);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- oldputblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip,15);
- break;
- case 0:
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- oldputblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip,15);
- break;
- }
- }
- static void OverCombo(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, byte skiprows=0)
- {
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- overblock8(_Dest, tile, x, y, w-w2, h, color, flip,15);
- overblock8(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip,15);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- overblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip,15);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- overblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip,15);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- overblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip,15);
- break;
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- overblock8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip,15);
- break;
- }
- }
- static void OverComboTranslucent(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, int opacity, byte skiprows=0)
- {
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- overblocktranslucent8(_Dest, tile, x, y, w-w2, h, color, flip, 15, opacity);
- overblocktranslucent8(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, 15, opacity);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, 15, opacity);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, 15, opacity);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, 15, opacity);
- break;
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, 15, opacity);
- break;
- }
- }
- static void PutComboTranslucent(BITMAP* _Dest, int tile, int x, int y, int w, int h, int color, int flip, int opacity, byte skiprows=0)
- {
- if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
- {
- byte w2=(tile+w)%TILES_PER_ROW;
- overblocktranslucent8(_Dest, tile, x, y, w-w2, h, color, flip, 15, opacity);
- overblocktranslucent8(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, 15, opacity);
- return;
- }
- switch(flip)
- {
- case 1:
- for(int j=0; j<h; j++)
- for(int k=w-1; k>=0; k--)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, 15,opacity);
- break;
- case 2:
- for(int j=h-1; j>=0; j--)
- for(int k=0; k<w; k++)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, 15, opacity);
- break;
- case 3:
- for(int j=h-1; j>=0; j--)
- for(int k=w-1; k>=0; k--)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, 15, flip, opacity);
- break;
- default:
- for(int j=0; j<h; j++)
- for(int k=0; k<w; k++)
- overblocktranslucent8(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, 15, opacity);
- break;
- }
- }
- };
- void do_drawcombor(BITMAP *bmp, int *sdci, int xoffset, int yoffset)
- {
- //sdci[1]=layer
- //sdci[2]=x
- //sdci[3]=y
- //sdci[4]=combo
- //sdci[5]=tile width
- //sdci[6]=tile height
- //sdci[7]=color (cset)
- //sdci[8]=scale x
- //sdci[9]=scale y
- //sdci[10]=rotation anchor x
- //sdci[11]=rotation anchor y
- //sdci[12]=rotation angle
- //sdci[13]=frame
- //sdci[14]=flip
- //sdci[15]=transparency
- //sdci[16]=opacity
- int w = sdci[5]/10000;
- int h = sdci[6]/10000;
- if(w<1||h<1||h>20||w>20)
- {
- return;
- }
- int xscale=sdci[8]/10000;
- int yscale=sdci[9]/10000;
- int rx = sdci[10]/10000; //these work now
- int ry = sdci[11]/10000; //these work now
- float rotation=sdci[12]/10000;
- bool transparency=sdci[15]!=0;
- int opacity=sdci[16]/10000;
- int color=sdci[7]/10000;
- int x1=sdci[2]/10000;
- int y1=sdci[3]/10000;
- //const newcombo & c = combobuf[(sdci[4]/10000)];
- int tiletodraw = sdci[4]/10000;
- //int tiletodraw = combo_tile(c, x1, y1);
- int flip = ((sdci[14]/10000) & 3) ^ c.flip;
- int skiprows=combobuf[(sdci[4]/10000)].skipanimy;
- //don't scale if it's not safe to do so
- bool canscale = true;
- if(xscale==0||yscale==0)
- {
- return;
- }
- if(xscale<0||yscale<0)
- canscale = false; //default size
- if((xscale>0 && yscale>0) || rotation) //scaled or rotated
- {
- BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
- if(transparency)
- {
- TileHelper::OverCombo(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
- }
- else //no transparency
- {
- TileHelper::OldPutCombo(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
- }
- if(rotation != 0) // rotate
- {
- //fixed point sucks ;0
- if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
- {
- int xy[2];
- fixed ra1=itofix(sdci[12]%10000)/10000;
- fixed ra2=itofix(sdci[12]/10000);
- fixed ra=ra1+ra2;
- xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
- xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
- x1=xy[0];
- y1=xy[1];
- }
- if(canscale) //scale first
- {
- BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
- clear_bitmap(tempbit);
- stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
- if(opacity < 128)
- {
- clear_bitmap(prim_bmp);
- rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
- draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
- }
- else
- {
- rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
- }
- destroy_bitmap(tempbit);
- }
- else //no scale
- {
- if(opacity < 128)
- {
- clear_bitmap(prim_bmp);
- rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
- draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
- }
- else
- {
- rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
- }
- }
- }
- else //scale only
- {
- if(canscale)
- {
- if(opacity<128)
- {
- clear_bitmap(prim_bmp);
- stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
- draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
- }
- else
- {
- stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
- }
- }
- else //error -do not scale
- {
- if(opacity<128)
- {
- draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
- }
- else
- {
- draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
- }
- }
- }
- script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
- }
- else // no scale or rotation
- {
- if(transparency)
- {
- if(opacity<=127)
- TileHelper::OverComboTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
- else
- TileHelper::OverCombo(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
- }
- else
- {
- if(opacity<=127)
- TileHelper::PutComboTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
- else
- TileHelper::OldPutCombo(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
- }
- }
- }
- void draw_mapscr(BITMAP *b, const mapscr& m, int x, int y, bool transparent)
- {
- for(int i(0); i < 176; ++i)
- {
- const int x2 = ((i&15)<<4) + x;
- const int y2 = (i&0xF0) + y;
- const newcombo & c = combobuf[ m.data[i] ];
- const int tile = combo_tile(c, x2, y2);
- if(transparent)
- overblocktranslucent8(b, tile, x2, y2, m.cset[i], c.flip, 15, 128);
- else
- overblock8(b, tile, x2, y2, m.cset[i], c.flip, 15);
- }
- }
- void do_fastcombor(BITMAP *bmp, int *sdci, int xoffset, int yoffset)
- {
- /* layer, x, y, tile, color opacity */
- int opacity = sdci[6] / 10000;
- int x1 = sdci[2] / 10000;
- int y1 = sdci[3] / 10000;
- int index = sdci[4]/10000;
- //if( index >= MAXCOMBOS ) return; //bleh.
- const newcombo & c = combobuf[index];
- if(opacity < 128)
- overblocktranslucent8(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int)c.flip, 15, opacity);
- else
- overblock8(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int)c.flip, 15);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement