In addition, you can use the stencil tools to help with masking out a layer that you've duplicated.
Create a new layer, and set the layer transparency to 50%. Use the paint tools to block in the area you want to mask. From the layer menu select 'Make a stencil from this layer'. Now delete or hide the layer you used to produce the mask.
If you need to, right-click on the stencil and select 'Invert the stencil'
You can now use the eraser tool to quickly remove non-masked areas of your copied layer.
AndyRage's mantra for graphics engine code:
"Sure - how hard can it be?"