Index: trunk/psastro/src/psastroMaskUpdates.c
===================================================================
--- trunk/psastro/src/psastroMaskUpdates.c	(revision 24653)
+++ trunk/psastro/src/psastroMaskUpdates.c	(revision 24701)
@@ -282,14 +282,45 @@
 		}
 
-		// select the raw objects for this readout, flag is they fall in a mask
-		psArray *rawstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.RAWSTARS");
-		if (rawstars == NULL) return false;
+		// this probably should move into a function of its own:
+		{
+		    // select the raw objects for this readout, flag is they fall in a mask
+		    psArray *inSources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
+		    if (inSources == NULL) continue;
 		
-		// XXX finish this: raise a bit for stars that land on certain types of masks;
-		// others (eg, bright star core) should be ignored.
-		for (int i = 0; false && (i < rawstars->n); i++) {
-		    pmAstromObj *raw = rawstars->data[i];
-		    psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[(int)(raw->chip->x)][(int)(raw->chip->y)];
-		    if (value) continue;
+		    // create a replacement output array:
+		    // psArray *outSources = psAllocArrayEmpty(100);
+
+		    // XXX finish this: raise a bit for stars that land on certain types of masks;
+		    // others (eg, bright star core) should be ignored.
+		    for (int i = 0; i < inSources->n; i++) {
+			pmSource *source = inSources->data[i];
+
+			int xChip = source->peak->x;
+			int yChip = source->peak->y;
+
+			bool onChip = true;
+			onChip &= (xChip >= 0);
+			onChip &= (xChip < readoutMask->mask->numCols);
+			onChip &= (yChip >= 0);
+			onChip &= (yChip < readoutMask->mask->numRows);
+			if (!onChip) {
+			    // if the source is off the edge of the chip, raise a different bit?
+			    source->mode |= PM_SOURCE_MODE_OFF_CHIP;
+			    continue;
+			}
+
+			psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
+			if (value & ghostMaskValue) {
+			    source->mode |= PM_SOURCE_MODE_ON_GHOST;
+			}
+			// XXX note that for now, glint and ghost are identical
+			pmSourceMode PM_SOURCE_MODE_ON_GLINT = PM_SOURCE_MODE_ON_GHOST;
+			if (value & glintMaskValue) {
+			    source->mode |= PM_SOURCE_MODE_ON_GLINT;
+			}
+			if (value & spikeMaskValue) {
+			    source->mode |= PM_SOURCE_MODE_ON_SPIKE;
+			}
+		    }
 		}
             }
