Method To Reduce Screen Resolution By Box Sampling

Is there a method I can implement to say, sample a 2x2 grid of pixels and downsize it to one pixel with the average color of the sample? (That is what box sampling is, right?) I need to modify some SDL games to fit on a 320x240 screen when they need >640x480. I know afterwards it’ll be a “needs more jpeg” meme magnet, but I can deal with that. (If your curious, it’s Ur-Quan Masters, OpenTTD and OpenRCT2.)