Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawPixel(x:uint,y:uint):uint {
- //layers are assumed to already be sorted correctly based on priorities
- const layers:Array=[OBJ_ALPHA,OBJ0,BG0,OBJ1,BG1,OBJ2,BG2,OBJ3,BG3];
- var hasFirstColor:Boolean=false;
- var allowBlend:Boolean=false;
- var isObjAlpha:Boolean=false;
- var outWindowEnabled:Boolean=window0.enabled || window1.enabled || oamWindow.enabled;
- if(window0.enabled && window0.pixelIn(x,y)) {
- allowBlend=window0.blend;
- } else if(window1.enabled && window1.pixelIn(x,y)) {
- allowBlend=window1.blend;
- } else if(oamWindow.enabled && oamWindow.pixelIn(x,y)) {
- allowBlend=oamWindow.blend;
- } else if(outWindowEnabled) {
- allowBlend=outWindowBlend;
- } else {
- allowBlend=true;
- }
- var firstColor:uint;
- var secondColor:uint;
- for each(var layer:Layer in layers) {
- if(!layer.enabled) continue;
- var layerColor:uint=layer.sample(x,y);
- if(isTransparent(layerColor)) continue;
- if(layer==OBJ_ALPHA) {
- isObjAlpha=true;
- allowBlend=true;
- }
- if(allowBlend && !isObjAlpha) {
- if(!hasFirstColor) {
- if(!layer.blendFromEnabled) continue;
- } else {
- if(!layer.blendToEnabled) continue;
- }
- }
- if(!hasFirstColor) {
- firstLayer=layerColor;
- hasFirstColor=true;
- if(!allowBlend) break;
- } else {
- secondColor=layerColor;
- break;
- }
- }
- if(!hasFirstColor) {
- firstColor=BG0.basicPalette[0];
- }
- var blendOpThisPixel:BlendOp=masterBlendOp;
- if(!isTransparent(secondColor) && isObjAlpha) {
- blendOpThisPixel=AlphaBlend;
- }
- return blendOpThisPixel(firstColor,secondColor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement