Replace 800x600 width a resolution from a .h file. Lots of positions are still hardco...
[ccbs] / bigscreen / splitscreen.cpp
index 10e3197..9d569b1 100644 (file)
@@ -9,10 +9,10 @@ SplitScreen::SplitScreen(GenericScreen *s1, GenericScreen *s2, GenericScreen *s3
        subscreens[2] = s3;
        subscreens[3] = s4;
 
-       memset(subbufs[0], 0, 800*600*4);
-       memset(subbufs[1], 0, 800*600*4);
-       memset(subbufs[2], 0, 800*600*4);
-       memset(subbufs[3], 0, 800*600*4);
+       memset(subbufs[0], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
+       memset(subbufs[1], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
+       memset(subbufs[2], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
+       memset(subbufs[3], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
 }
 
 SplitScreen::~SplitScreen()
@@ -41,27 +41,27 @@ void SplitScreen::draw(unsigned char *buf)
        }
        
        downscale_2x2(buf, subbufs[0]);
-       downscale_2x2(buf + 400 * 4, subbufs[1]);
-       downscale_2x2(buf + 800 * 300 * 4, subbufs[2]);
-       downscale_2x2(buf + 800 * 300 * 4 + 400 * 4, subbufs[3]); 
+       downscale_2x2(buf + (SCREEN_WIDTH/2) * 4, subbufs[1]);
+       downscale_2x2(buf + SCREEN_WIDTH * (SCREEN_HEIGHT/2) * 4, subbufs[2]);
+       downscale_2x2(buf + SCREEN_WIDTH * (SCREEN_HEIGHT/2) * 4 + (SCREEN_WIDTH/2) * 4, subbufs[3]); 
 
        // make divider lines
-       unsigned char *ptr = buf + 300 * 800 * 4;
-       for (unsigned x = 0; x < 800; ++x) {
+       unsigned char *ptr = buf + (SCREEN_HEIGHT/2) * SCREEN_WIDTH * 4;
+       for (unsigned x = 0; x < SCREEN_WIDTH; ++x) {
                *ptr++ = 255;
                *ptr++ = 255;
                *ptr++ = 255;
                *ptr++ = 0;
        }
        
-       ptr = buf + 400 * 4;
-       for (unsigned y = 0; y < 600; ++y) {
+       ptr = buf + (SCREEN_WIDTH/2) * 4;
+       for (unsigned y = 0; y < SCREEN_HEIGHT; ++y) {
                ptr[0] = 255;
                ptr[1] = 255;
                ptr[2] = 255;
                ptr[3] = 0;
 
-               ptr += 800 * 4;
+               ptr += SCREEN_WIDTH * 4;
        }
        
        valid = true;
@@ -70,12 +70,12 @@ void SplitScreen::draw(unsigned char *buf)
 // simple box filter (blah)
 void SplitScreen::downscale_2x2(unsigned char *dst, unsigned char *src)
 {
-       for (unsigned y = 0; y < 300; ++y) {
-               unsigned char *sptr1 = src + (y*2) * 800 * 4;
-               unsigned char *sptr2 = src + (y*2+1) * 800 * 4;
-               unsigned char *dptr = dst + y * 800 * 4;
+       for (unsigned y = 0; y < (SCREEN_HEIGHT/2); ++y) {
+               unsigned char *sptr1 = src + (y*2) * SCREEN_WIDTH * 4;
+               unsigned char *sptr2 = src + (y*2+1) * SCREEN_WIDTH * 4;
+               unsigned char *dptr = dst + y * SCREEN_WIDTH * 4;
                
-               for (unsigned x = 0; x < 400; ++x) {
+               for (unsigned x = 0; x < (SCREEN_WIDTH/2); ++x) {
                        *dptr++ = (sptr1[0] + sptr1[4] + sptr2[0] + sptr2[4]) >> 2;  // red
                        *dptr++ = (sptr1[1] + sptr1[5] + sptr2[1] + sptr2[5]) >> 2;  // green
                        *dptr++ = (sptr1[2] + sptr1[6] + sptr2[2] + sptr2[6]) >> 2;  // blue